Help with a Matrix for different angles

Greetings,
I am running the following code and I want to find out the value of sigma1, sigma2, and tau6 at each angle starting from 0. I was thinking of doing a for-lopp, but the problem is that I am not able to do negative thetas or 0.
I think the problem is that MatLAb is taking ALL the angles and creating one big solution based on all angles? i might be wrong here, but any help to achieve my goal would be greatly appreciated
theta=0:5:90;
m=cosd(theta);
n=sind(theta);
sigma1=sym('sigma_1');
sigma2=sym('sigma_2');
tau6=sym('tau_6');
stress=[sigma1; sigma2; tau6];
sigmax=0;
sigmay=0;
tau5=sym('taus');
stress_rotation=[sigmax; sigmay; tau5];
T=[m.^2 n.^2 2.*m.*n;
n.^2 m.^2 -2.*m.*n;
-m.*n m.*n m.^2-n.^2];
equation=stress==T.*stress_rotation;
solution=solve(equation, stress);
sigma1_f=vpa(solution.sigma_1);
sigma2_f=vpa(solution.sigma_2);
tau6_f=vpa(solution.tau_6);

9 Kommentare

John D'Errico
John D'Errico am 28 Mär. 2021
There is no reason to post the same question twice.
Eddy Ramirez
Eddy Ramirez am 28 Mär. 2021
wasnt sure if it went through the first time, but thank you for your feedback
darova
darova am 30 Mär. 2021
I see 4 uknowns but only 3 equations
Eddy Ramirez
Eddy Ramirez am 30 Mär. 2021
yes - I want to get the values of sigma1, sigma2, and tau6 when i run the equation "stress==T.*stress_rotation" so for example when i run a 45* angle I get the following
Sigma1=taus
Sigma2=-taus
tau6=0
but when I run multiple angles, it does not work and I am not sure how to fix it
darova
darova am 30 Mär. 2021
Use for loop
Eddy Ramirez
Eddy Ramirez am 30 Mär. 2021
Would the for loop allow me to run negative angles as well? I tried to do a for loop but it only allows me start with 1 through N.
Try this way
ang = [-30 25 15];
for i = 1:length(ang)
% code
end
yeah still no luck, i might have to recode it i just find it weird that a for loop doesnt do the trick. I wrote it as shown below but it does not work at all
theta=0:5:90;
m=cosd(theta);
n=sind(theta);
m2=m.^2;
n2=n.^2;
for i=1:length(theta)
T=[m2(i) n2(i) 2.*m(i).*n(i);
n2(i) m2(i) -2.*m(i).*n(i);
-m(i)*n(i) m(i)*n(i) m2(i)-n2(i)];
sigma1=sym('sigma_1');
sigma2=sym('sigma_2');
tau6=sym('tau_6');
stress=[sigma1; sigma2; tau6];
sigmax=0;
sigmay=0;
tau5=sym('taus');
stress_rotation=[sigmax; sigmay; tau5];
equation=stress(i)==T.*stress_rotation(i);
solution=solve(equation, stress);
sigma1_f=vpa(solution.sigma_1);
sigma2_f=vpa(solution.sigma_2);
tau6_f=vpa(solution.tau_6);
end
stress=[sigma1; sigma2; tau6];
That is a vector of length 3
equation=stress(i)==T.*stress_rotation(i);
but you index it at i where i can be up to length(theta)
Also your stress_rotation vector is length 3 as well.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Gefragt:

am 28 Mär. 2021

Kommentiert:

am 31 Mär. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by