早教吧作业答案频道 -->其他-->
matlab 程序出错,帮我看看错在哪儿了函数function dvdt=huxi(t,v) global W L A po pc pn t v P0 P xo xc xn ro rcdvdt=[A/L*po*(xo*P0/100-v(1)/(v(1)+v(2)+v(3)+v(4))*P)-ro*W;A/L*pc*(xc*P0/100-v(2)/(v(1)+v(2)+v(3)+v(4))*P)+rc*W;A/L*pn*(xn*P0/10
题目详情
matlab 程序出错,帮我看看错在哪儿了
函数
function dvdt=huxi(t,v)
global W L A po pc pn t v P0 P xo xc xn ro rc
dvdt=[
A/L*po*(xo*P0/100-v(1)/(v(1)+v(2)+v(3)+v(4))*P)-ro*W;
A/L*pc*(xc*P0/100-v(2)/(v(1)+v(2)+v(3)+v(4))*P)+rc*W;
A/L*pn*(xn*P0/100-v(3)/(v(1)+v(2)+v(3)+v(4))*P);
0
];
运行
t_start=0;
t_end=1;
vv0=[yo0*V/100;yc0*V/100;yn0*V/100;ye0*V/100];
for ro=romin:0.1:romax
for rc=rcmin:0.1:rcmax
[t,v]=ode45('huxi',[t_start,t_end],vv0);
yo=v(end,1)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yc=v(end,2)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yn=v(end,3)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
if yo(1)==yoend/100 & yc(1)==ycend/100
break
ro
rc
end
end
end
说明
其中的参数如W,A,L,po,pc,pn,V,yo0,yc0,yn0,romax,romin,rcmax,rcmin,yoend,ycend等,已经在前面通过输入赋值了.
出错
Error using ==> funfun\private\odearguments
Solving HUXI requires an initial condition vector of length 2.
Error in ==> ode45 at 173
[neq,tspan,ntspan,next,t0,tfinal,tdir,y0,f0,odeArgs,odeFcn,...
%把程序补充完整了
function dvdt=huxi(t,v)
global W L A po pc pn P0 P xo xc xn ro rc;
dvdt=zeros(4,1);
dvdt=[
A/L*po*(xo*P0/100-v(1)/(v(1)+v(2)+v(3)+v(4))*P)-ro*W;
A/L*pc*(xc*P0/100-v(2)/(v(1)+v(2)+v(3)+v(4))*P)+rc*W;
A/L*pn*(xn*P0/100-v(3)/(v(1)+v(2)+v(3)+v(4))*P);
0];
%运行
W=0.106;L=0.012/1000;A=600/10000;V=500;
po=0.032498;pc=0.044255;pn=0.03837;
yo0=20.9;yc0=0.03;yn0=78.08;ye0=100-yo0-yc0-yn0;
romax=190;romin=150;rcmax=190;rcmin=150;
yoend=17.6;ycend=3.4;
xo=20.95;xc=0.03;xn=78.08;P0=101000;P=101000;
t_start=0;
t_end=1;
vv0=[yo0*V/100;yc0*V/100;yn0*V/100;ye0*V/100]; %初值
for ro=romin:0.1:romax
for rc=rcmin:0.1:rcmax
[t,v]=ode45('huxi',[t_start,t_end],vv0);
yo=v(end,1)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yc=v(end,2)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yn=v(end,3)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
if yo(1)==yoend/100 & yc(1)==ycend/100
ro
rc
end
end
end
函数
function dvdt=huxi(t,v)
global W L A po pc pn t v P0 P xo xc xn ro rc
dvdt=[
A/L*po*(xo*P0/100-v(1)/(v(1)+v(2)+v(3)+v(4))*P)-ro*W;
A/L*pc*(xc*P0/100-v(2)/(v(1)+v(2)+v(3)+v(4))*P)+rc*W;
A/L*pn*(xn*P0/100-v(3)/(v(1)+v(2)+v(3)+v(4))*P);
0
];
运行
t_start=0;
t_end=1;
vv0=[yo0*V/100;yc0*V/100;yn0*V/100;ye0*V/100];
for ro=romin:0.1:romax
for rc=rcmin:0.1:rcmax
[t,v]=ode45('huxi',[t_start,t_end],vv0);
yo=v(end,1)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yc=v(end,2)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yn=v(end,3)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
if yo(1)==yoend/100 & yc(1)==ycend/100
break
ro
rc
end
end
end
说明
其中的参数如W,A,L,po,pc,pn,V,yo0,yc0,yn0,romax,romin,rcmax,rcmin,yoend,ycend等,已经在前面通过输入赋值了.
出错
Error using ==> funfun\private\odearguments
Solving HUXI requires an initial condition vector of length 2.
Error in ==> ode45 at 173
[neq,tspan,ntspan,next,t0,tfinal,tdir,y0,f0,odeArgs,odeFcn,...
%把程序补充完整了
function dvdt=huxi(t,v)
global W L A po pc pn P0 P xo xc xn ro rc;
dvdt=zeros(4,1);
dvdt=[
A/L*po*(xo*P0/100-v(1)/(v(1)+v(2)+v(3)+v(4))*P)-ro*W;
A/L*pc*(xc*P0/100-v(2)/(v(1)+v(2)+v(3)+v(4))*P)+rc*W;
A/L*pn*(xn*P0/100-v(3)/(v(1)+v(2)+v(3)+v(4))*P);
0];
%运行
W=0.106;L=0.012/1000;A=600/10000;V=500;
po=0.032498;pc=0.044255;pn=0.03837;
yo0=20.9;yc0=0.03;yn0=78.08;ye0=100-yo0-yc0-yn0;
romax=190;romin=150;rcmax=190;rcmin=150;
yoend=17.6;ycend=3.4;
xo=20.95;xc=0.03;xn=78.08;P0=101000;P=101000;
t_start=0;
t_end=1;
vv0=[yo0*V/100;yc0*V/100;yn0*V/100;ye0*V/100]; %初值
for ro=romin:0.1:romax
for rc=rcmin:0.1:rcmax
[t,v]=ode45('huxi',[t_start,t_end],vv0);
yo=v(end,1)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yc=v(end,2)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yn=v(end,3)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
if yo(1)==yoend/100 & yc(1)==ycend/100
ro
rc
end
end
end
▼优质解答
答案和解析
问题所在:
Solving HUXI requires an initial condition vector of length 2.
初始条件长度为2,这儿有问题,(实际应该是4吧)
只能说明函数的定义不满足条件
改一下函数定义:
function dvdt=huxi(t,v)
global W L A po pc pn P0 P xo xc xn ro rc %去掉t v ,但应该不是主要问题
dvdt=zeros(4,1);%主要是检测函数有用
dvdt=[
A/L*po*(xo*P0/100-v(1)/(v(1)+v(2)+v(3)+v(4))*P)-ro*W;
A/L*pc*(xc*P0/100-v(2)/(v(1)+v(2)+v(3)+v(4))*P)+rc*W;
A/L*pn*(xn*P0/100-v(3)/(v(1)+v(2)+v(3)+v(4))*P);
0];
从你给的信息只能看到这些了,如果还有问题,信息再详细点
直接拷贝下面代码也可以运行
function solFOUND
global W L A po pc pn P0 P xo xc xn ro rc;
W=0.106;L=0.012/1000;A=600/10000;V=500;
po=0.032498;pc=0.044255;pn=0.03837;
yo0=20.9;yc0=0.03;yn0=78.08;ye0=100-yo0-yc0-yn0;
yoend=17.6;ycend=3.4;
xo=20.95;xc=0.03;xn=78.08;P0=101000;P=101000;
romax=190;romin=150;rcmax=190;rcmin=150;
t_start=0;
t_end=1;
vv0=[yo0*V/100;yc0*V/100;yn0*V/100;ye0*V/100]; %初值
for ro=romin %改回原来的
for rc=rcmin %改回原来的
[t,v]=ode45(@huxi,[t_start,t_end],vv0);
yo=v(end,1)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yc=v(end,2)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yn=v(end,3)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
if yo(1)==yoend/100 & yc(1)==ycend/100
ro
rc
end
end
end
function dvdt=huxi(t,v)
global W L A po pc pn P0 P xo xc xn ro rc;
dvdt=zeros(4,1);
dvdt=[
A/L*po*(xo*P0/100-v(1)/(v(1)+v(2)+v(3)+v(4))*P)-ro*W;
A/L*pc*(xc*P0/100-v(2)/(v(1)+v(2)+v(3)+v(4))*P)+rc*W;
A/L*pn*(xn*P0/100-v(3)/(v(1)+v(2)+v(3)+v(4))*P);
0];
Solving HUXI requires an initial condition vector of length 2.
初始条件长度为2,这儿有问题,(实际应该是4吧)
只能说明函数的定义不满足条件
改一下函数定义:
function dvdt=huxi(t,v)
global W L A po pc pn P0 P xo xc xn ro rc %去掉t v ,但应该不是主要问题
dvdt=zeros(4,1);%主要是检测函数有用
dvdt=[
A/L*po*(xo*P0/100-v(1)/(v(1)+v(2)+v(3)+v(4))*P)-ro*W;
A/L*pc*(xc*P0/100-v(2)/(v(1)+v(2)+v(3)+v(4))*P)+rc*W;
A/L*pn*(xn*P0/100-v(3)/(v(1)+v(2)+v(3)+v(4))*P);
0];
从你给的信息只能看到这些了,如果还有问题,信息再详细点
直接拷贝下面代码也可以运行
function solFOUND
global W L A po pc pn P0 P xo xc xn ro rc;
W=0.106;L=0.012/1000;A=600/10000;V=500;
po=0.032498;pc=0.044255;pn=0.03837;
yo0=20.9;yc0=0.03;yn0=78.08;ye0=100-yo0-yc0-yn0;
yoend=17.6;ycend=3.4;
xo=20.95;xc=0.03;xn=78.08;P0=101000;P=101000;
romax=190;romin=150;rcmax=190;rcmin=150;
t_start=0;
t_end=1;
vv0=[yo0*V/100;yc0*V/100;yn0*V/100;ye0*V/100]; %初值
for ro=romin %改回原来的
for rc=rcmin %改回原来的
[t,v]=ode45(@huxi,[t_start,t_end],vv0);
yo=v(end,1)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yc=v(end,2)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
yn=v(end,3)/(v(end,1)+v(end,2)+v(end,3)+v(end,4));
if yo(1)==yoend/100 & yc(1)==ycend/100
ro
rc
end
end
end
function dvdt=huxi(t,v)
global W L A po pc pn P0 P xo xc xn ro rc;
dvdt=zeros(4,1);
dvdt=[
A/L*po*(xo*P0/100-v(1)/(v(1)+v(2)+v(3)+v(4))*P)-ro*W;
A/L*pc*(xc*P0/100-v(2)/(v(1)+v(2)+v(3)+v(4))*P)+rc*W;
A/L*pn*(xn*P0/100-v(3)/(v(1)+v(2)+v(3)+v(4))*P);
0];
看了 matlab 程序出错,帮我...的网友还看了以下:
正规算子及其伴随有相同的本征向量为什么有对T是正规算子的假设?假设T是V上的算子.a是T的本征值. 2020-04-26 …
高中化学在定T,V的情况下,对于反应前后气体体积不变的可逆反应,为什么只要反应物的物质的量比例与原 2020-05-09 …
matlab 程序出错,帮我看看错在哪儿了函数function dvdt=huxi(t,v) gl 2020-05-16 …
matlab画 v-t 图的程序 错在哪了?k=0.22;m=75;g=9.8;x=sqrt(m* 2020-05-16 …
谁能把我把这些公式弄成手写公式s(t)=at^2/2+v(0)t=(v(t)^2-v(0)^2)/ 2020-05-16 …
曲线y=ex+e−x2与直线x=0,x=t(t>0)及y=0围成一曲边梯形.该曲边梯形绕x轴旋转一 2020-06-14 …
a=2x/t^2和a=x/t^2a的定义是a=△v/△t△v=v-v0认为v0=0△v=v△t=t 2020-07-11 …
matlab用电压V=10伏的电池给电容器充电,电容器上t时刻的电压为v(t)=v-(v-v(0) 2020-07-19 …
为什么曲线运动速度矢量可以写成v(t)=v(t)v^(t)v(t)=v(t)v^(t)上的那个^是 2020-08-03 …
s听=(v声t-v车t)的二分之一是求什么的(初二上物理)s听=(v声t-v车t)的二分之一还有s除 2020-11-02 …