Convert a cell array that contains numbers and NaN values to a matrix
32 views (last 30 days)
Show older comments
I have a cell array Acceleration {131341x1} that contains NaN and numbers. I tried to use the cell2mat like
Acc = cell2mat (Acceleration);
but I get following error:
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 83)
m{n} = cat(1,c{:,n});
Any idea how can I solve the problem?
Thanks!
0 Comments
Answers (1)
Jan
on 5 Apr 2017
The elements of the cell do not have the same size:
W = cellfun('ndims', Acceleration);
isequal(length(unqiue(W)), 1)
S = cellfun('size', Acceleration, 2);
unique(S)
If you have different number of columns, how should the result look like? It does not matter if the values contain NaNs, but only if the sizes match.
4 Comments
See Also
Categories
Find more on Data Type Conversion 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!