フィルターのクリア

how to store n matrix in an other matrix of size n

3 ビュー (過去 30 日間)
loukil sana
loukil sana 2016 年 5 月 20 日
コメント済み: loukil sana 2016 年 5 月 20 日
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
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?
loukil sana
loukil sana 2016 年 5 月 20 日
*First, i will create: * mat1(4,6) * mat2(4,6) * mat3(4,2) * and a value (an integer) * Then, i will execute those 3 matrices+the integer N time. * Finaly, i create the matrix of (N,4) just to memories those results that i have cited(the matrices+the integer)

サインインしてコメントする。

採用された回答

John D'Errico
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
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.
loukil sana
loukil sana 2016 年 5 月 20 日
ok now i have done that but when i do the implementation it doesn't post up the matrices with values ... but juste the dimmension of the matrices. And an other thing is that it post up juste the last raw of the matrix and not all the raws that he has memoriesed
--------------------------------------------------------------
Matrix containing the initial population of 5 individual
[] [] [] []
[] [] [] []
[4x6 double] [4x6 double] [4x2 double] [19]
[] [] [] []
[] [] [] []

サインインしてコメントする。

その他の回答 (2 件)

parth pandya
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 件のコメント
loukil sana
loukil sana 2016 年 5 月 20 日
Thank you sir. But i have something that can't work with that. Can i have your email that i can send you my code if it's possible. thakns My mail is: loukil.sanaa@gmail.com
parth pandya
parth pandya 2016 年 5 月 20 日
my mail is : parthindia47@gmail.com. can't you post your code here?

サインインしてコメントする。


Azzi Abdelmalek
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
  2 件のコメント
loukil sana
loukil sana 2016 年 5 月 20 日
thanks for your answer, but no matrices don't have the same size. *mat1(4,6) *mat2(4,6) *mat3(4,2) *and i have a value also (integer)
loukil sana
loukil sana 2016 年 5 月 20 日
i have to mention that the 3 matrices containt values( they are a result). In other word, i create the matrix of (N,3) just to memories the result i get each time because i need them later.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by