Azzera filtri
Azzera filtri

cell to double using cell2mat

4 visualizzazioni (ultimi 30 giorni)
Dylan Mecca
Dylan Mecca il 12 Feb 2018
Commentato: Star Strider il 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)

Risposta accettata

Star Strider
Star Strider il 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 Commenti
Dylan Mecca
Dylan Mecca il 12 Feb 2018
I've attached a sample of the data my project is using. I am using 2014a unfortunately. Do you have another suggestion for converting this data to double? My first inclination is to use cell2mat but it returns my data as char. Do you know of another conversion, possibly, to change char to double?
Star Strider
Star Strider il 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’.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by