Conversion of {} in () with cell2table
Show older comments
I have this cell array :

I do this command :
data = cell2table(data, 'VariableNames',{'Date' 'ap' 'cp'});
And I have this :

My problem is that the third column has the {} (like data.cp{61,1} in the example), while the second column has the () (like data.ap(61,1) in the example)
Why do I get this ? And how can I fix it ? I would like to have () for both
Thanks
Accepted Answer
More Answers (1)
Peter Perkins
on 19 Oct 2017
0 votes
It's impossible to say for sure what is happening because all you've posted is a screenshot. My best guess is that you started with a 67x3 cell array, the first column of which contained a char row vector in each cell (a date string, actually), the second column of which contained a scalar struct in each cell, and the tird column of which contatined a mix of scalar structys and [].
I'm guess that the table you got from cell2table containned three variables: 1) a cellstr containing date strings, which you like want to convert to a datetime vector, 2) a 67x1 struct, although it may also have been left as a 67x1 cell array containing scalar structs if the fields were different, and 3) a 67x1 cell array containing a mix of scalar structs and []
I think you need to work a bit more on these data to get them into a more useful form, especially the last thing.
Categories
Find more on Data Type Identification 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!