【Matlab】解个微分方程
生活随笔
收集整理的這篇文章主要介紹了
【Matlab】解个微分方程
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
v˙l=alv˙f=?0.1+5?vf+0.25?vf2mD˙=vl?vf\begin{aligned} & \dot{v}_l = a_l \\ & \dot{v}_f = -\frac{0.1 + 5*v_f + 0.25 * v_f^2}{m} \\ & \dot{D} = v_l - v_f \\ \end{aligned}?v˙l?=al?v˙f?=?m0.1+5?vf?+0.25?vf2??D˙=vl??vf??
%% Solve Differential Equations % Author: Zhao-Jichao % Date: 2021-07-18 clear clc%% Initial Parameters % Variable initial values vl0 = 1; vf0 = 2; D0 = 3;%% Solve ODE % Time parameters tBegin = 0; tFinal = 10; in = [vl0 vf0 D0]'; [t, out] = ode45(@odeFun, [tBegin, tFinal], in);%% Draw Results subplot(2,2,1) plot(t,out(:,1), t,out(:,2), t,out(:,3), 'linewidth',1.5); legend('v_l', 'v_f', 'D'); grid on;subplot(2,2,2) plot(t,out(:,1), 'linewidth',1.5); hold on ; legend('v_l'); grid on;subplot(2,2,3) plot(t,out(:,2), 'linewidth',1.5); hold on ; legend('v_f'); grid on;subplot(2,2,4) plot(t,out(:,3), 'linewidth',1.5); hold on ; legend('D'); grid on;%% Ode SubFunction function out = odeFun(~, in)vl = in(1,:);vf = in(2,:);D = in(3,:);al = 1;m = 1;% Set up differential relationsdvl = al;dvf = -(0.1 + 5*vf + 0.25*vf^2) / (m);dD = vl - vf;out = [dvl; dvf; dD]; endof
總結
以上是生活随笔為你收集整理的【Matlab】解个微分方程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Paper】2017_Limit-Cy
- 下一篇: 【CoppeliaSim】远程 API