2x2 matrix that changes with iteration of for loop
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
David Fariyike
le 27 Juin 2020
Commenté : David Fariyike
le 27 Juin 2020
Hello,
I am trying to define a 2x2 matrix that changes with each increment of a for loop. This is what I currently have but it only gives me 1 2x2 matrix.
for ii=1:length(tt),
J={-L1*s1(ii)-L2*s12(ii) -L2*s12(ii);
L1*c1(ii)+L2*c12(ii) L2*c12(ii)};
end
I am not defining everything for simplicity purposes. But s1(ii), s12(ii), c1(ii), and c12(ii) are all solved in the for loop and each a 1x5001 matrix. The L1 and L2 are constants. I am trying to define J as a 2x2 matrix 5001 times.
0 commentaires
Réponse acceptée
madhan ravi
le 27 Juin 2020
s1 = reshape(s1,1,1,[]);
s12 = reshape(s12,1,1,[]);
c1 = reshape(c1,1,1,[]);
c12 = reshape(c12,1,1,[]);
J = [-L1*s1-L2*s12, -L2*s12;
L1*c1+L2*c12, L2*c12]
1 commentaire
Plus de réponses (0)
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!