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

 Respuesta aceptada

Birdman
Birdman el 19 de Oct. de 2017

0 votos

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 comentarios

Louis TERRATS
Louis TERRATS el 19 de Oct. de 2017
Editada: Louis TERRATS el 19 de Oct. de 2017
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 el 19 de Oct. de 2017
Probably it has something to do with notation. You don't have to think about it.
Louis TERRATS
Louis TERRATS el 19 de Oct. de 2017
Yes ! It was a problem in my notation Thanks for help

Iniciar sesión para comentar.

Más respuestas (1)

Peter Perkins
Peter Perkins el 19 de Oct. de 2017

0 votos

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.

Categorías

Preguntada:

el 19 de Oct. de 2017

Respondida:

el 19 de Oct. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by