我可以将矩阵的单元格数组转换为矩阵:
>> C={[1,1]; [2,2]; [3,3]};
>> cell2mat(C)
ans =
1 1
2 2
3 3
Run Code Online (Sandbox Code Playgroud)
还行吧.但是,我想将包含其他单元格数组的单元格数组转换为矩阵:
>> C={{1,1}; {2,2}; {3,3}};
>> cell2mat(C)
Error using cell2mat (line 53)
Cannot support cell arrays containing cell arrays or objects.
Run Code Online (Sandbox Code Playgroud)
所以,期望的输出是:
>> mycell2mat({{1,1}; {2,2}; {3,3}})
ans =
1 1
2 2
3 3
Run Code Online (Sandbox Code Playgroud)
这该怎么做?
我也想对多维的做同样的事情:
>> mycell2mat({{1,1;1,1}; {2,2;2,2}; {3,3;3,3}})
ans(:,:,1) =
1 1
1 1
ans(:,:,2) =
2 2
2 2
ans(:,:,3) =
3 3
3 3
Run Code Online (Sandbox Code Playgroud) matlab ×1