How do you open .csv files?

8 ビュー (過去 30 日間)
Thomas
Thomas 2014 年 1 月 28 日
編集済み: Thomas 2014 年 1 月 28 日
For my dissertation, my data is in a .csv file format, yet I've tried using this code to read in data. I don't understand what is going wrong. Matlab says there is a problem with the usage line, but what? The other I have done is put the name of the file. Could anyone solve my simple problem.
if (nargin ~= 1 ) usage(); end
fd = fopen(fname,'data.csv');
if (fd == -1)
msg = sprintf('File %s not opened\n',fname);
disp(msg);
return;
end
  1 件のコメント
Thomas
Thomas 2014 年 1 月 28 日
what is usage()? is it a user function?

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

採用された回答

Thomas
Thomas 2014 年 1 月 28 日
編集済み: Thomas 2014 年 1 月 28 日
Just try
fname='data.csv'
fd = fopen(fname);
if (fd == -1)
msg = sprintf('File %s not opened\n',fname);
disp(msg);
return;
end
If such a file (data.csv) does not exist in the directory then you will get the error message as return

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by