MATLAB Answers

0

cell2mat error

Asked by Diogo Carvalho on 16 Apr 2019
Latest activity Commented on by Diogo Carvalho on 16 Apr 2019
Accepted Answer by KSSV
I have the following cell array:
C =
4×1 cell array
{'1 1 3 2' }
{'2 3 5 2' }
{'3 4 5 3' }
{'4 1 4 3 '}
and wish to turn its contents into a matrix, but when I use cell2mat on it it outputs "Error using cat
Dimensions of arrays being concatenated are not consistent."
I've tried using str2double but it just outputs NaN.

  0 Comments

Sign in to comment.

Products

1 Answer

KSSV
Answer by KSSV
on 16 Apr 2019
 Accepted Answer

C = [{'1 1 3 2' }
{'2 3 5 2' }
{'3 4 5 3' }
{'4 1 4 3 '}] ;
C = cell2mat(cellfun(@str2num,C,'UniformOutput',false))

  1 Comment

Diogo Carvalho on 16 Apr 2019
awesome, thanks.

Sign in to comment.