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