create cell array by extracting all the same row from multiple matrix
1 次查看(过去 30 天)
显示 更早的评论
I have three double A = [105x3]; B = [105x3]; C = [105x3]; I want to create a cell array D = {105 cells} each cells contains the corresponding rows from A B C.
For example,
D {1} = [
A(1,:);
B(1,:);
C(1,:);]
each row from A B C are in different rows in D
Is this achievable through cellfun?
0 个评论
采纳的回答
Stephen23
2022-9-28
"Is this achievable through cellfun?"
Yes:
A = rand(105,3);
B = rand(105,3);
C = rand(105,3);
D = cellfun(@vertcat,num2cell(A,2),num2cell(B,2),num2cell(C,2), 'uni',0)
But most likely you should be using ND arrays rather than concatenating & splitting data like that.
2 个评论
Stephen23
2022-10-1
"But I am not sure I understand the 'using ND arrays' in your suggestion."
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!