- 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!