How to construct a table with several matrices
Mostra commenti meno recenti
Hi.
Is is possible to construct a table in MATLAB that contains four matrices? That is, if I were to have four matrices:
Sigma1 = [1 0.5; 0.5 1];
Sigma2 = [1 -0.5; -0.5 1];
Sigma3 = [0.4 1; 8.0 2.0];
Sigma4 = [8.0 2; 0.2 0.1];
Could I put this into a table that has two ColumnName and two RowName, but each "value "in the table is one Sigma matrix? Can you please help me?
Risposta accettata
Più risposte (4)
Azzi Abdelmalek
il 26 Set 2012
Modificato: Azzi Abdelmalek
il 26 Set 2012
A={sigma1,sigma2;sigma3,sigma4}
2 Commenti
Image Analyst
il 26 Set 2012
Well, in your original post you said "table" and that is kind of ambiguous. A table could be a cell array/matrix, like Azzi (and I) initially thought, or it could be a uitable like you've now clarified in your comments. See my answer regarding uitable.
Thomas
il 26 Set 2012
Or you could form a 3D matrix; where each 3rd dimension is an individual Sigma matrix
Sigma1 = [1 0.5; 0.5 1];
Sigma2 = [1 -0.5; -0.5 1];
Sigma3 = [0.4 1; 8 2];
Sigma4 = [8 2; 0.2 0.1];
Sigma(:,:,1)=Sigma1;
Sigma(:,:,2)=Sigma2;
Sigma(:,:,3)=Sigma3;
Sigma(:,:,4)=Sigma4;
Sigma
1 Commento
Babak
il 26 Set 2012
mytable=cell(2,2);
mytable{1,1}=[1 0.5; 0.5 1];
mytable{1,2}=[1 -0.5; -0.5 1];
mytable{2,1}=[0.4 1; 8.0 2.0];
mytable{2,2}=[8.0 2; 0.2 0.1];
mytable % display it
2 Commenti
Lily
il 26 Set 2012
Image Analyst
il 26 Set 2012
Babak - see her response to Tom. The "table" she wants is a uitable, not a cell array.
Image Analyst
il 26 Set 2012
0 voti
I'm pretty sure you can't have a 2 by 2 array in one "cell" (here I'm using Excel's definition of cell, not MATLAB's definition of cell) of a uitable. The cells in a uitable can only be single numbers or strings.
As a workaround, you can have a blank (empty) separator column or row in between a 2 by 2 block of cells by putting in null for those rows or columns that you want blank. This will give the appearance of having those 2x2 arrays of numbers separated from each other.
1 Commento
Lily
il 26 Set 2012
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!