フィルターのクリア

FOR loop with subs :: NEED HELP

3 ビュー (過去 30 日間)
Ali Tawfik
Ali Tawfik 2019 年 2 月 7 日
コメント済み: Walter Roberson 2019 年 2 月 8 日
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

採用された回答

Walter Roberson
Walter Roberson 2019 年 2 月 7 日
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 件のコメント
Ali Tawfik
Ali Tawfik 2019 年 2 月 8 日
Maybe I have to add angle(i)?, and I think I can get the result without the problem of sind and cosd..
Walter Roberson
Walter Roberson 2019 年 2 月 8 日
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, [])));

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by