csvread doesn't work, I just get errors.
25 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to import data from a data logger in csv format, this site says
"M = csvread('FILENAME',R,C)" is how you do that but I tried "m=csvread('LOGGER02.CSV',C5); disp(m);", but all I get is
Undefined function or variable 'C5'.
Error in untitled (line 1) m=csvread('LOGGER02.CSV',C5);
whats the real way to read csv files, assuming Matlab can read/import them? I'm using R2017b
0 件のコメント
回答 (2 件)
Aarti Dwivedi
2018 年 7 月 24 日
R = 1
C5 = 1
m=csvread('LOGGER02.CSV',R, C5); disp(m);
The error is pretty straightforward that your variable definitions are missing. Just saying C5 doesn't mean that the cell address is C5. C5 is the name of the variable in which you will store the column offset.
19 件のコメント
Walter Roberson
2018 年 7 月 25 日
The simplest way is
t = readtable('LOGGER02.CSV', 'HeaderLines', 1, 'ReadVariableName', false);
temperature = t{:,2}; %or as appropriate
humidity = t{:,4}; %or as appropriate
If you have R2016b or later, you can use detectImportOptions and set the SelectedVariables property to cause it to throw away everything else when you use readtable()
For older versions of MATLAB, before R2013b, then probably it would be best to use fopen()/textscan()/fclose() . This requires knowing the format of the columns you are skipping.
Image Analyst
2018 年 7 月 24 日
If "C5" is the column/row you see when you open it in Excel, then row = 5 and column = 3, and csvread() expects integers for offsets, not actual row or column numbers (i.e. 4 and 2):
Starting row offset, specified as a nonnegative integer. The first row has an offset of 0.
Starting column offset, specified as a nonnegative integer. The first column has an offset of 0.
so try
m=csvread('LOGGER02.CSV', 4, 2);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!