matlab ode45求解常微分方程模板

1、内容简介

matlab ode45求解常微分方程模板
307-可以交流、咨询、答疑

2、内容说明

matlab ode45求解常微分方程模板

3、仿真分析

主函数:

clc
close all
clear
tspan = [0 100];
x0 = [0 -1 0 -1]';
[t,x]=ode45('fun',tspan,x0);
figure
plot(t,x(:,1))
xlabel 时间/s
ylabel u1
figure
plot(t,x(:,2))
xlabel 时间/s
ylabel du1/dt

figure
plot(t,x(:,3))
xlabel 时间/s
ylabel u2
figure
plot(t,x(:,4))
xlabel 时间/s
ylabel du2/dt

子函数

function y = fun(t,x)

%---------------
y=zeros(4,1);
y(1)=x(2);
y(2)=-x(2)+x(4)+100*sin(10*t)+150*(x(3)-x(1));y(2)=y(2)/2.25;
y(3)=x(4);
y(4)=x(2)-x(4)+150*(x(1)-x(3));y(4)=y(4)/2;

 

4、参考论文


 

猜你喜欢

转载自blog.csdn.net/qingfengxd1/article/details/125197347