Plotting Results of a Matrix from a For Loop Help
Afficher commentaires plus anciens
Hey guys, this is a snippet of my code I can't seem to get to graph. S is a 3x3 matrix and I need to plot points (1,1), (2,2) and (3,3) of the transformed 3x3 Sxy matrix for values of theta from 0:90. How to I get the figures to work and not just be blank? I would very much appreciate help with this. So far I've tried using the 'hold on' and moving the plot functions inside the for loop.
I would do this without the for loop but the matrix S does not change with each iteration so without the for loop, the inner matrix indices do not match.
for theta=0:90
% Angles
c=cosd(theta);
s=sind(theta);
% Transformation Matrix
T=[c.^2 s.^2 2.*c.*s; s.^2 c.^2 -2.*c.*s; -c.*s c.*s c.^2-s.^2];
Tinv=[c.^2 s.^2 -2.*c.*s; s.^2 c.^2 2.*c.*s; c.*s -c.*s c.^2-s.^2];
% Coordinate Transformations
Sxy=Tinv*S*T;
Exx=1/Sxy(1,1);
Eyy=1/Sxy(2,2);
Gxy=(1/Sxy(3,3))/2;
end
figure(1)
plot(theta,Exx)
xlabel('Theta in Degrees')
ylabel('Exx')
figure(2)
plot(theta,Eyy)
xlabel('Theta in Degrees')
ylabel('Eyy')
figure(3)
plot(theta,Gxy)
xlabel('Theta in Degrees')
ylabel('Gxy')
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!