function dydt=xuexi(t,y,Cph,Cpl,Cp,Bt,Rp,Ft,Ct,Cg,Tg);
dydt=zeros(3,1);
dydt(1)=y(1)*(y(1)-1)*(cph-cpl-cp-bt-y(2)*(rp-bt)-y(3)*(fp+mp));
end
figure(1)
Rp=100,Cph=85,Cpl=0,Cp=10,Bt=40,Fp=40,Mp=20,Ct=10,Ft=20,Mt=15,Cg=15,Tg=40;
set(0,'defaultfigurecolor','w');
[t,y]=ode45(@(t,y)xuexi(t,y,Cph,Cpl,Cp,Bt,Rp,Ft,Ct,Cg,Tg),[0 50],[0.2 0.2 0.2]);
plot3(y(:,1),y(:,2),y(:,3),'r+','linewidth',1);
hold on;
这个是一部分,但是运行的时候提示:出错[t,y]=ode45(@(t,y)xuexi(t,y,Cph,Cpl,Cp,Bt,Rp,Ft,Ct,Cg,Tg),[0 50],[0.2 0.2 0.2]);也就是ode这一行有问题,想知道有什么问题?

 Accepted Answer

需要看一下变量的对应关系
更多代码请参考
clc; clear all; close all;
figure(1)
Rp=100;Cph=85;Cpl=0;Cp=10;Bt=40;Fp=40;Mp=20;Ct=10;Ft=20;Mt=15;Cg=15;Tg=40;
% set(0,'defaultfigurecolor','w');
[t,y]=ode45(@(t,y)xuexi(t,y,Cph,Cpl,Cp,Bt,Rp,Ft,Ct,Cg,Tg,Fp,Mp),[0 50],[0.2 0.2 0.2]);
plot3(y(:,1),y(:,2),y(:,3),'r+','linewidth',1);
hold on;
function dydt=xuexi(t,y,Cph,Cpl,Cp,Bt,Rp,Ft,Ct,Cg,Tg,Fp,Mp)
dydt=zeros(3,1);
dydt(1)=y(1)*(y(1)-1)*(Cph-Cpl-Cp-Bt-y(2)*(Rp-Bt)-y(3)*(Fp+Mp));
end

More Answers (0)

Categories

Find more on 数学 in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!