put all cells in one column cellfun

2 views (last 30 days)
NA
NA on 24 Jan 2019
Commented: madhan ravi on 24 Jan 2019
I have
q1={[1],[3],[4]};
q2={[1;3],[3;4],[4;5]};
q3={[1;2;3;4;5;5],[1;2;3;4;5;67],[1;6;3;4;9;67]};
I use this code but not working
out= cellfun(@(w,e,r)(w;e;r),q1,q2,q3,'uni',0);
out={[1;1;3;1;2;3;4;5;5],[3;3;4;1;2;3;4;5;67],[4;4;5;1;6;3;4;9;67]}

Accepted Answer

madhan ravi
madhan ravi on 24 Jan 2019
out= cellfun(@(w,e,r)[w;e;r],q1,q2,q3,'uni',0);
% ^-----^------- square bracket!
  2 Comments
Stephen23
Stephen23 on 24 Jan 2019
Edited: Stephen23 on 24 Jan 2019
Correct brackets solves the problem. A simpler solution: @vertcat
madhan ravi
madhan ravi on 24 Jan 2019
Agree with stephen:
out= cellfun(@vertcat,q1,q2,q3,'un',0);

Sign in to comment.

More Answers (0)

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!