Conversion of {} in () with cell2table

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

 採用された回答

Birdman
Birdman 2017 年 10 月 19 日

0 投票

That paranthesis styles mean different things. If you use (), the answer is in cell type. If you use {}, the answer is in double type. Like I said, their usages are different.

3 件のコメント

Louis TERRATS
Louis TERRATS 2017 年 10 月 19 日
編集済み: Louis TERRATS 2017 年 10 月 19 日
Thanks for reminder. But I still don't understand why I have different data types between column 2 and 3 after the cell2table transformation. Because, before this transformation I had the same data types
Birdman
Birdman 2017 年 10 月 19 日
Probably it has something to do with notation. You don't have to think about it.
Louis TERRATS
Louis TERRATS 2017 年 10 月 19 日
Yes ! It was a problem in my notation Thanks for help

サインインしてコメントする。

その他の回答 (1 件)

Peter Perkins
Peter Perkins 2017 年 10 月 19 日

0 投票

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.

カテゴリ

ヘルプ センター および File ExchangeData Type Identification についてさらに検索

質問済み:

2017 年 10 月 19 日

回答済み:

2017 年 10 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by