how to store n matrix in an other matrix of size n
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, i have a loop FOR i=1:N. For each 'i', i have to create 3 matrices that i want to store in the position 'i' of a new matrix(N,3). How can i do that? Thanks
댓글 수: 2
parth pandya
2016년 5월 20일
편집: parth pandya
2016년 5월 20일
Your Main matrix will be (N,3) size.
what is size of 3 matrices you are going to create?
& what do you mean by 'i' position?
Can you explain?
채택된 답변
John D'Errico
2016년 5월 20일
편집: John D'Errico
2016년 5월 20일
Learn what a cell array is, how to use them, how to define them.
doc cell
You can also do similar things with structs.
댓글 수: 3
John D'Errico
2016년 5월 20일
편집: John D'Errico
2016년 5월 20일
So? A cell array can contain anything.
N = 10;
C = cell(N,3);
C{1,1} = pi;
C{1,2} = rand(3,3);
C1,3} = 'The sky is falling!';
etc.
추가 답변 (2개)
parth pandya
2016년 5월 20일
you can try this:
N = 1;
MainMatrix = cell(N,4);
Result1 = zeros(4,6);
Result2 = zeros(4,6);
Result3 = zeros(4,2);
i = 2;
MainMatrix{1,1} = Result1;
MainMatrix{1,2} = Result2;
MainMatrix{1,3} = Result3;
MainMatrix{1,4} = i;
Also you can read
doc struct
댓글 수: 2
Azzi Abdelmalek
2016년 5월 20일
편집: Azzi Abdelmalek
2016년 5월 20일
If your matrices have the same size (nxm), you can use nxmxp matrix. For example
A1=[1 2;3 4;5 6];
A2=[7 8;9 10;1 1];
You can create the matrix B:
[n,m]=size(A1);
p=2;
B=zeros(n,m,p);
B(:,:,1)=A;
B(:,:,2)=B;
B
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!