cell to double using cell2mat
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dylan Mecca
am 12 Feb. 2018
Kommentiert: Star Strider
am 12 Feb. 2018
Hi everyone,
I'm looking to take a variable from a spreadsheet I import to be plotted. I've done some poking around and found that you cannot plot a cell style import of data and needs to be converted to double. So I used the cell2mat command, but the return was char. I don't know what this means, but it is still giving me errors when I try to plot.
A = cell2mat(Time)
0 Kommentare
Akzeptierte Antwort
Star Strider
am 12 Feb. 2018
I’m guessing here, because I don’t have an example of your data.
Dates and times are frequently imported as character arrays. The easiest way to import them is as a datetime (link) array (in R2014b and later releases). You can then work with them and convert them to date numbers if necessary.
The other fields of your data you can use with cell2mat if necessary.
2 Kommentare
Star Strider
am 12 Feb. 2018
I use xlsread to read the file. This code produces the correct date numbers, that you can then use as you wish in your code:
[d,s,r] = xlsread('20180122Mx00_Go-Stop CE(US)0001.CSV');
DateN = datenum(s(2:end,1), 'yyyy-mm-dd');
The first row of ‘Date’ is the word 'Date' itself, so it is necessary to begin with row 2. I am not certain what the ‘Time’ data represent. If they are decimal fractions of a day, just add them to ‘DateN’, since that is how date numbers operate in MATLAB. If they represent something else, you will have to convert them into fractions of a day, first, beofre adding them to ‘DateN’.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!