- 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 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
Torsten
2022 年 8 月 20 日
編集済み: Torsten
2022 年 8 月 20 日
採用された回答
Paul
2022 年 8 月 20 日
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 件のコメント
Paul
2022 年 8 月 21 日
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,:))
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!