matlab solve函数变量问题clcP=[0.9110 0.6777 0.7706 ];D=[2.656E+09 7.968E+10 2.656E+10];[x,y]=solve('y*log((x+D(3))/(x+D(1)))/log(10)=(P(1)-P(3))','y*log((x+D(3))/(x+D(2)))/log(10)=(P(2)-P(3))','x','y');%xx=solve('y*log((x+2.656E+10)/(x+2.656E+0
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/26 01:38:20
matlab solve函数变量问题clcP=[0.9110 0.6777 0.7706 ];D=[2.656E+09 7.968E+10 2.656E+10];[x,y]=solve('y*log((x+D(3))/(x+D(1)))/log(10)=(P(1)-P(3))','y*log((x+D(3))/(x+D(2)))/log(10)=(P(2)-P(3))','x','y');%xx=solve('y*log((x+2.656E+10)/(x+2.656E+0
matlab solve函数变量问题
clc
P=[0.9110 0.6777 0.7706 ];
D=[2.656E+09 7.968E+10 2.656E+10];
[x,y]=solve('y*log((x+D(3))/(x+D(1)))/log(10)=(P(1)-P(3))','y*log((x+D(3))/(x+D(2)))/log(10)=(P(2)-P(3))','x','y');
%xx=solve('y*log((x+2.656E+10)/(x+2.656E+09))/log(10)=(0.9110-0.7706)','y*log((x+2.656E+10)/(x+7.968E+10))/log(10)=(0.6777-0.7706)');
x=subs(x)
y=subs(y)
De=x
C=y
A=P(3)+C*log(1+D(3)/De)/log(10)
运行结果:
Warning:Explicit solution could not be found.
> In solve at 81
In jisuande at 4
x =
[]
y =
[]
De =
[]
C =
[]
Error using ==> mrdivide
Matrix dimensions must agree.
Error in ==> jisuande at 10
A=P(3)+C*log(1+D(3)/De)/log(10)
为什么前面的数组调用不了,请明白的同志给讲一下,最好能给出能正确运行的程序
我决定自己编一个遗传算法或者布伦特算法程序来解决这个问题,想偷个懒看来还不行
matlab solve函数变量问题clcP=[0.9110 0.6777 0.7706 ];D=[2.656E+09 7.968E+10 2.656E+10];[x,y]=solve('y*log((x+D(3))/(x+D(1)))/log(10)=(P(1)-P(3))','y*log((x+D(3))/(x+D(2)))/log(10)=(P(2)-P(3))','x','y');%xx=solve('y*log((x+2.656E+10)/(x+2.656E+0
没看到x和y根本就没解出来么,
Warning:Explicit solution could not be found.
警告:显式解未找到.
_____________________________
matlab不是万能的,人没办法解matlab当然也没法解,就算数组代入也还是解不了的.
solve有两种用法,一种是像你这样用字符串作为参数,在这种情况下字符串被整体传到函数内,不会自动将已定义的内容代到字符串内.因此必须手动拼接字符串,用num2str将数字转换为字符串,再和其他字符串接到一起成为一个整体,再传给solve,比较麻烦.第二种是输入符号表达式,这样比较简单,下面我用这种方法给出你的问题的写法,但是即使数组被传入了,solve依然解不出显式解,这不是我个人所能解决的.
clc
P=[0.9110 0.6777 0.7706 ];
D=[2.656E+09 7.968E+10 2.656E+10];
syms x y
[x,y]=solve(y*log((x+D(3))/(x+D(1)))/log(10)-(P(1)-P(3)),y*log((x+D(3))/(x+D(2)))/log(10)-(P(2)-P(3)),x,y);
%xx=solve('y*log((x+2.656E+10)/(x+2.656E+09))/log(10)=(0.9110-0.7706)','y*log((x+2.656E+10)/(x+7.968E+10))/log(10)=(0.6777-0.7706)');
x=subs(x)
y=subs(y)
De=x
C=y
A=P(3)+C*log(1+D(3)/De)/log(10)
还有我想说,solve一般用于求解析解,数值解并不擅长,求数值解还是用fsolve比较合适.
___________
大概版本不一样,反正我的没求出来.