Table to array error

I have a table "Data" that has values like this:
2017-10-05 '21:55:00' 48.3 48.305 48.23 48.24 61636 0
2017-10-05 '22:00:00' 48.24 48.25 48.215 48.25 2.4483e+05 0
etc...
When I say
tmpData=table2array(Data);
I get an error:
Error using table2array (line 27) Cannot concatenate the table variables 'Date' and 'Time', because their types are datetime and cell.
Error in ReadTradeStationData (line 9) tmpData=table2array(Data);
Is there a workaround?

Risposte (1)

Peter Perkins
Peter Perkins il 13 Ott 2017

0 voti

Ivan, by calling table2array, you are asking to put different data types into a homogeneous array. That isn't gong to work.
It's kind of hard to say from what you've provided, but it looks like you have a table with one datetime variable, one cellstr variable (which youd' probably want as a duration, or perhaps combined with the datetime), and six numeric variables. That's what tables are for: collecting mixed-type column-wise data.
It's not clear what you want to create. By calling table to array, you are in effect saying, "horzcat all these variable together and give me the result". But you can't horzcat those three different data types, and I think that's the whole reason you have them in a table to begin with, right? You could certainly apply table to cell, but I doubt the result would be what you want.

Categorie

Prodotti

Richiesto:

il 6 Ott 2017

Risposto:

il 13 Ott 2017

Community Treasure Hunt

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

Start Hunting!

Translated by