How to deal with CELL2MAT does not support cell arrays containing cell arrays or objects?

10 ビュー (過去 30 日間)
Hi all,
I am trting to do this:
Px_a1_val = {(sq_val{1, 1}(:,1)) (jp_val{1, 1}(:,1)) (walk_val{1, 1}(:,1)) (stair_as_val{1, 1}(:,1)) (stair_de_val{1, 1}(:,1))};
Px_a1_val = cell2mat(Px_a1_val);
which gives me this:
CELL2MAT does not support cell arrays containing cell arrays or objects.
Can you help please?
  2 件のコメント
Matt J
Matt J 2022 年 3 月 23 日
What shoudl the result be?
Tomaszzz
Tomaszzz 2022 年 3 月 23 日
matrix of
(sq_val{1, 1}(:,1)) (jp_val{1, 1}(:,1)) (walk_val{1, 1}(:,1)) (stair_as_val{1, 1}(:,1)) (stair_de_val{1, 1}(:,1)

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

採用された回答

Matt J
Matt J 2022 年 3 月 23 日
編集済み: Matt J 2022 年 3 月 23 日
A=num2cell(num2cell(eye(3)),1)
A = 1×3 cell array
{3×1 cell} {3×1 cell} {3×1 cell}
cell2matRecursive(A)
ans = 3×3
1 0 0 0 1 0 0 0 1
function B=cell2matRecursive(B)
if ~iscell(B{1})
B=cell2mat(B);
else
B=cellfun(@cell2matRecursive,B,'uni',0);
B=cell2mat(B);
end
end

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by