필터 지우기
필터 지우기

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
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개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by