fill matrix from cell matrix

2 ビュー (過去 30 日間)
Targh dadou
Targh dadou 2018 年 5 月 5 日
コメント済み: Targh dadou 2018 年 5 月 5 日
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

採用された回答

Ameer Hamza
Ameer Hamza 2018 年 5 月 5 日
You need to index into Cell array C.
A{j} = B{j}(:, C{j});
In your code, to used C as the index itself.
  1 件のコメント
Targh dadou
Targh dadou 2018 年 5 月 5 日
thank you,the problem is solved.

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

その他の回答 (0 件)

カテゴリ

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