create cell array by extracting all the same row from multiple matrix
Show older comments
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?
Accepted Answer
More Answers (1)
D = cell(105,5) ;
for i = 1:105
D{i} = [A(i,:) B(i,:) C(i,:)] ;
end
Or
D = [A B C] ;
D = num2cell(D,2) ;
2 Comments
Katherine Zheng
on 28 Sep 2022
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!