Cell2mat - creating a matrix from mismatched cell sizes
Show older comments
Does anyone know how to create a matrix from a cell array where some of the cells have different lengths? Basically my instrument got interrupted when writing it's output file and finished halfway through a line. I don't want to discard the file as it's 99% complete. Is there another command which selectively converts a given sample size of a cell?
4 Comments
Cedric
on 16 Jan 2013
What is the structure of your data (cell array, valid cells content, invalid cells content)?
Karen Hornsby
on 17 Jan 2013
Matt J
on 17 Jan 2013
If your data is initially acquired as a file, how did it get into cell array form? Why would you import the file to a cell array if you ultimately want it to be a vector?
Samira Abedi
on 2 Jan 2019
I get the following error when applying the above code:
Attempt to grow array along ambiguous dimension.
Accepted Answer
More Answers (2)
Jan
on 17 Jan 2013
What do you want as output for:
C = {[], 1, 1:2}
?
2 Comments
Karen Hornsby
on 17 Jan 2013
Jan
on 17 Jan 2013
No, "C" is a cell, which contains vectors of different length. Simply copy it to the command window and run it. It is exactly what you have explained by:
... a cell array where some of the cells have different lengths?
Now you ask us for creating a matrix from such an input. So how should the output look like in this case?
Samira Abedi
on 2 Jan 2019
0 votes
I get the following error when I apply the suggested method:
Attempt to grow array along ambiguous dimension.
Categories
Find more on Time Series Events in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!