- Please include your code as plain ascii, not as a graphics.
- Some variables in the code you posted are undefined. So even if we took the time to write down your code again, we cannot test it.
- What do you mean by But when I try to make a matrix 2x2 with those variables as it's components, it doesn't work. What is the error message you get ?
Define matrix array as functions
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am a student, and looking for any kind help to correct my work bellow :
I define some variables as function of cos (t), and when I run this program, it works, no error information at the command window, and also they do have the same length.
But when I try to make a matrix 2x2 with those variables as it's components, it doesn't work. I would be grateful if somebody will kindly help me to fix it. Here my program I try to do.
Thank you.
2 commentaires
Torsten
le 20 Août 2022
Modifié(e) : Torsten
le 20 Août 2022
Réponse acceptée
Paul
le 20 Août 2022
If you're trying to store M1 for all values of n, then M1 needs to be 2 x 2 x n
M1(:,:,n) = [M1a(n) M1b(n);M1c(n) M1d(n)];
Consider preallocation of all the varaibles being assigned to.
4 commentaires
Paul
le 21 Août 2022
If M1 and M2 are both 2 x 2 x n, and M3 is 2 x 2 x n, and each page of M3 should be the product of the corresponding pages of M1 and M2, then use pagemtimes
M3 = pagemtimes(M1,M2)
M3 is now 2 x 2 x n. The (1,1) elements of the pages of M3 is then
M3a = M3(1,1,:);
M3a = squeeze(M3a); % or M3a = squeeze(M3(1,1,:))
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!