fopen fails to open the file

30 views (last 30 days)
William
William on 10 Sep 2012
Hi there,
small example file (test.m):
if true
clear all; clc;
disp(fopen('C:/test/test.csv'));
disp(fopen('test.csv'));
end
my current directory is also C:/test/ and the file (test.csv) exits as well.
but still both lines of code return the value -1 which indicates that the file couldn't be found and I don't know why.
Any hint?

Accepted Answer

Sean de Wolski
Sean de Wolski on 10 Sep 2012
Is test.csv opened in another application?
  1 Comment
William
William on 10 Sep 2012
awwww man, so stupid -.- *facepalm
many thanks

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 10 Sep 2012
[fid, message] = fopen('test.csv');
if fid < 0; disp(message); end

Community Treasure Hunt

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

Start Hunting!