Create matrix of vector from 3 differents cell array

2 views (last 30 days)
Hi,
I have the followinf three cell arrays
a = {[1 0 1 0 1 0 0 0 1 1] , [1 1 1 0 0 0 1 0 1 0 1], [1 0 1 0 1 0 1 1 1 1 0 0 0 0]};
b = {[1 0 1 1 1 0 1 0 0 1] , [1 0 0 0 0 0 1 1 1 0 1], [1 1 1 1 1 0 1 0 0 1 0 0 0 0]};
c = {[1 0 1 1 1 0 1 0 0 1] , [1 0 0 0 0 0 1 1 1 0 1], [1 1 1 1 1 0 1 0 0 1 0 0 0 0]};
I would like to create new cell arrays. the number of cell arrays to be created are equal to length(a).
The first cell array should contain the first arrays of each cell arrays
A = {[1 0 1 0 1 0 0 0 1 1], [1 0 1 1 1 0 1 0 0 1], [1 0 1 1 1 0 1 0 0 1]}
The second cell array should contain the second arrays of each cell arrays
B = {[1 1 1 0 0 0 1 0 1 0 1], [1 0 0 0 0 0 1 1 1 0 1], [1 0 0 0 0 0 1 1 1 0 1]}
The third cell array should contain the third arrays of each cell arrays
C = {[1 0 1 0 1 0 1 1 1 1 0 0 0 0], [1 1 1 1 1 0 1 0 0 1 0 0 0 0] , [1 1 1 1 1 0 1 0 0 1 0 0 0 0]}
How can I do to obtain this result?
The length of a should vary, so it's necessary a loop that consider how many arrays are contained in a.

Accepted Answer

madhan ravi
madhan ravi on 1 Aug 2019
W = cellfun(@(x,y,z) {x,y,z},a,b,b,'un',0) % W{1} is A and so on

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!