fill matrix from cell matrix
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
HELLO,
I have a cell matrix B (1 * 67 cell), each cell contains a matrix of type N * N C is a cell matrix of type 1 * 67 cell, each cell contains a matrix of type 1 * M I want to fill A from B by respecting the column number indicated in C
for j=1:67
A{j}=B{j}(:,C);
end
error Function 'subsindex' is not defined for values of class 'cell
EXEMPLE for a cell of the matrix
B'=
1 5 3 4 5 6 9 1
4 5 6 7 8 9 8 9
7 8 9 6 5 4 1 2
9 8 7 6 5 4 5 6
1 2 3 4 5 6 1 2
9 8 7 6 5 4 2 3
7 5 8 8 6 9 7 8
C'= 2 7 8
So A'=
5 9 1
5 8 9
8 1 2
8 5 6
2 1 2
8 2 3
5 7 8
I'm trying to convert the cell matrix into a table matrix
Tabl= cell2table(B);
Ta = cell2table(C);
A=Tabl(:,Ta);
error using "Table variable subscripts must be real positive integers, logicals, strings, or cell arrays of strings."
Do you have an idea
thank you in advance
0 commentaires
Réponse acceptée
Ameer Hamza
le 5 Mai 2018
You need to index into Cell array C.
A{j} = B{j}(:, C{j});
In your code, to used C as the index itself.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!