FOR loop with subs :: NEED HELP
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali Tawfik
am 7 Feb. 2019
Kommentiert: Walter Roberson
am 8 Feb. 2019
Hi All,
I've been trying to implement a for loop to obtain different values of the following matrix (T_x_new), it's working perfect till obtaining normal T_x_new, so I just would like to add different theta for T_x_new to check different values but it's not working
Would any one mind helping me to run this code:
clear all;
syms l1 m1 n1 l2 m2 n2 l3 m3 n3 theta real;
T_x= [l1^2 m1^2 n1^2 2*m1*n1 2*l1*n1 2*l1*m1;
l2^2 m2^2 n2^2 2*m2*n2 2*l2*n2 2*l2*m2;
l3^2 m3^2 n3^2 2*m3*n3 2*l3*n3 2*l3*m3;
l2*l3 m2*m3 n2*n3 m2*n3+n2*m3 l2*n3+n2*l3 l2*m3+m2*l3;
l1*l3 m1*m3 n1*n3 m1*n3+n1*m3 l1*n3+n1*l3 l1*m3+m1*l3;
l1*l2 m1*m2 n1*n2 m1*n2+n1*m2 l1*n2+n1*l2 l1*m2+m1*l2];
T_x_new=subs(T_x,{l1,m1,n1,l2,m2,n2,l3,m3,n3},{1,0,0,0,cos(theta),sin(theta),0,-sin(theta),cos(theta)});
for i=45:90;
theta=i*(pi/180);
T_x_new(:,:,i)
end
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 7 Feb. 2019
for i=45:90;
theta=i*(pi/180);
subs(T_x_new)
end
This will produce 46 matrices of output, so you may wish to reconsider using 45:90 rather than (say) 45:15:90
8 Kommentare
Walter Roberson
am 8 Feb. 2019
angle = [0 45 30 20 90];
num = length(angle);
for i=1:num;
w(:,:,i)=double( subs(T_x_new, theta, angle(i)) );
end
Or alternately,
angle = [0 45 30 20 90];
w = double(subs(T_x_new, theta, reshape(angle, 1, 1, [])));
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Number Theory finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!