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?
답변 (1개)
Peter Perkins
2017년 10월 13일
0 개 추천
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.
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!