MATLAB Answers

convert cell to array

12 views (last 30 days)
NA on 15 Feb 2019
Commented: Badreddine Alane on 27 Jan 2020
I have
C = cellfun(@(x)x(x~=0),A,'uni',false);
I want to conver this cell to array, result should be:
I tried to use cell2mat(A) but have this error
Error using cat
Dimensions of arrays being concatenated are not consistent.
Error in cell2mat (line 75)
m{n} = cat(2,c{n,:});


Sign in to comment.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 15 Feb 2019
out = cat(1,A{:});
out = out(out ~= 0);

  1 Comment

Badreddine Alane
Badreddine Alane on 27 Jan 2020
Thank you so much for the help.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!