How to solve error in executing for loop due to Solve command used?

1 vue (au cours des 30 derniers jours)
Shantanu K
Shantanu K le 1 Avr 2013
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?

Réponse acceptée

Walter Roberson
Walter Roberson le 1 Avr 2013
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);

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by