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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Files and Folders에 대해 자세히 알아보기

질문:

2014년 1월 28일

편집:

2014년 1월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by