Implement following matrix using for loop
Afficher commentaires plus anciens
I want implement the following matrix and expression:
%Big_lambda
where theta,r,t are 1*3 matrix and a,b,p,q are 1*1 matrix.
My approach:
theta = [ 45 46 48] ;
t= [ 1 2 3 ];
r= [200 210 220];
for i=1:3
dif_x = [(-cos(theta(i))) (r(i).*sin(theta(i))) (2*a.*t(i)+b);...
(-sin(theta(i))) (-r(i).*cos(theta(i))) (2*p.*t(i)+q)]
W = dif_x(i)*Big_lambda(i)*dif_x(i)'
end
Is the approach correct or if it is wrong what should be done!
Thanks in advance.
7 commentaires
Bob Thompson
le 15 Mai 2019
Your approach generally seems fine, although I'm not really sure why you have W indexed. Do you want to multiply individual elements, or the entire matrix?
Is there something wrong with what you have written? Are you getting any error messages? Please explain more, or post the entire error message.
madhan ravi
le 15 Mai 2019
Tipu Sultan
le 15 Mai 2019
Tipu Sultan
le 15 Mai 2019
Bob Thompson
le 15 Mai 2019
You have still not indicated what exactly your problem is.
Tipu Sultan
le 15 Mai 2019
Modifié(e) : Tipu Sultan
le 15 Mai 2019
Bob Thompson
le 15 Mai 2019
Modifié(e) : Bob Thompson
le 15 Mai 2019
As far as I can tell you are going in the correct direction. I am not a SME on your specific problem, but for the code aspect it seems to be functional.
I noticed you adjusted your indexing on dif_x. Don't forget to index W as well if you want to retain the results from each loop, instead of just the final loop.
W(i) = dif_x(:,:,i)*Big_lambda(i)*dif_x(:,:,i)'
Réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

