How to solve error in executing for loop due to Solve command used?
1 次查看(过去 30 天)
显示 更早的评论
angle=90;
theta=angle*pi/180;
m=cos(theta);
n=sin(theta);
%Sig1=Sigx*m^2+Sigy*n^2+2*m*n*Sigxy;
%Sig2=Sigx*n^2+Sigy*m^2-2*m*n*Sigxy;
%Sig6=Sigx*m*n+Sigy*n*m+(m*m-n*n)*Sigxy;
S1=1500;
S2=40;
S6=68;
for z=1:1500
Sigx(z)=z;
Sy=solve('(((z*m^2+Sigy*n^2)^2/(S1*S1))+((z*n^2+Sigy*m^2)^2/(S2*S2))+((z*m*n+Sigy*n*m)^2/(S6*S6))-(((z*m^2+Sigy*n^2)*(z*n^2+Sigy*m^2))/(S1*S1))=1)');
Sigy(z)=Sy;
end
plot(Sigx, Sigy);
There is error in executing solve command....How to solve this?
采纳的回答
Walter Roberson
2013-4-1
Please note that when you use a quoted string as the argument to solve, then variables you have defined at the MATLAB level are not given those values for the purposes of solve(): they are treated as symbolic variables with unknown values. Then, because you have not indicated which of the symbolic variables to solve for, solve will try to solve for all of them and will fail because there are not enough equations to solve them simultaneously.
My guess at what you are trying to do is:
syms Sigy
for z=1:1500
Sigx(z)=z;
Sy(z) = solve( (((z*m^2+Sigy*n^2)^2/(S1*S1))+((z*n^2+Sigy*m^2)^2/(S2*S2))+((z*m*n+Sigy*n*m)^2/(S6*S6))-(((z*m^2+Sigy*n^2)*(z*n^2+Sigy*m^2))/(S1*S1))-1), Sigy);
end
Sigy = double(Sy);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!