MATLAB在求解微分方程的时候怎么同时输出所求函数的导数?(使用ode45的同时输出微分方程结果)
以Van Del Pol这样一个微分方程为例:
求解这样一个微分方程,MATLAB代码如下:
tspan=0:0.01:15;
q0=[2;0];%初值 [q;q']
[t,q]=ode45(@vdp1,tspan,q0);
plot(t,q(:,1),t,q(:,2))
title('Solution of van der Pol Equation (\mu = 1) with ODE45');
xlabel('Time t');
ylabel('Solution q dq');
legend('q_
原创
2021-06-26 11:38:08 ·
1657 阅读 ·
3 评论