Matlab大神求助这个代码错误怎么解?
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/11/08 21:34:40
Matlab大神求助这个代码错误怎么解?
t=[1;2;3]; ppi=[90;80;70]; [n,m]=size(t); aa=zeros(n,m)bb=zeros(n,m)for i=1:2:n-1t1= t(i,1);t2=t(n,1);pp=ppi(i,1);ppn= ppi(n,1)% [a,b]=solve(' x/t(i,1)-(ln(1/(1-90/100)))^(1/y)=0','x/2-(ln(1/(1-80/100)))^(1/y)=0'); [a,b]=solve('x/t1-(ln(1/(1-pp/100)))^(1/y)=0','x/tn-(ln(1/(1- ppn/100)))^(1/y)=0');a1=double(a);b1=double(b);aa(i,1)=a1;bb(i,1)=b1;endaabb错误提示:DOUBLE cannot convert the input expression into a double array.If the input expression contains a symbolic variable,use the VPA functioninstead.
t=[1;2;3]; ppi=[90;80;70]; [n,m]=size(t); aa=zeros(n,m)bb=zeros(n,m)for i=1:2:n-1t1= t(i,1);t2=t(n,1);pp=ppi(i,1);ppn= ppi(n,1)% [a,b]=solve(' x/t(i,1)-(ln(1/(1-90/100)))^(1/y)=0','x/2-(ln(1/(1-80/100)))^(1/y)=0'); [a,b]=solve('x/t1-(ln(1/(1-pp/100)))^(1/y)=0','x/tn-(ln(1/(1- ppn/100)))^(1/y)=0');a1=double(a);b1=double(b);aa(i,1)=a1;bb(i,1)=b1;endaabb错误提示:DOUBLE cannot convert the input expression into a double array.If the input expression contains a symbolic variable,use the VPA functioninstead.
t=[1;2;3];
ppi=[90;80;70];
[n,m]=size(t);
aa=zeros(n,m);
bb=zeros(n,m);
for i=1:2:n-1
t1= t(i,1);
t2=t(n,1);
pp=ppi(i,1);
ppn= ppi(n,1)
[a,b]=solve(' x/t-(ln(1/(1-90/100)))^(1/y)=0','x/2-(ln(1/(1-80/100)))^(1/y)=0');
%[a,b]=solve('x/t1-(ln(1/(1-pp/100)))^(1/y)=0','x/t2-(ln(1/(1- ppn/100)))^(1/y)=0');
t=t1;
a=subs(a)
b=subs(a)
a1=double(a);
b1=double(b);
aa(i,1)=a1;
bb(i,1)=b1;
end
aa
bb
原来的程序,主要的错误是:[a,b]=solve(……),这个命令得到的解含有符号变量(contains a symbolic variable),不能直接用double命令,必须先用subs()命令来替换里面的符号变量,才能用double命令.
ppi=[90;80;70];
[n,m]=size(t);
aa=zeros(n,m);
bb=zeros(n,m);
for i=1:2:n-1
t1= t(i,1);
t2=t(n,1);
pp=ppi(i,1);
ppn= ppi(n,1)
[a,b]=solve(' x/t-(ln(1/(1-90/100)))^(1/y)=0','x/2-(ln(1/(1-80/100)))^(1/y)=0');
%[a,b]=solve('x/t1-(ln(1/(1-pp/100)))^(1/y)=0','x/t2-(ln(1/(1- ppn/100)))^(1/y)=0');
t=t1;
a=subs(a)
b=subs(a)
a1=double(a);
b1=double(b);
aa(i,1)=a1;
bb(i,1)=b1;
end
aa
bb
原来的程序,主要的错误是:[a,b]=solve(……),这个命令得到的解含有符号变量(contains a symbolic variable),不能直接用double命令,必须先用subs()命令来替换里面的符号变量,才能用double命令.