フィルターのクリア

cell to double using cell2mat

4 ビュー (過去 30 日間)
Dylan Mecca
Dylan Mecca 2018 年 2 月 12 日
コメント済み: Star Strider 2018 年 2 月 12 日
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)

採用された回答

Star Strider
Star Strider 2018 年 2 月 12 日
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 件のコメント
Dylan Mecca
Dylan Mecca 2018 年 2 月 12 日
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 2018 年 2 月 12 日
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’.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by