MATLAB: I am getting an ‘Unable to open file.’ error with importdata

errorimportdataunable to open file

Hi,
I am trying to open a text (sample.txt) file in MATLAB using importdata function. But I am getting an error for the following code. Please see sample.txt file is attached. (it does not have a header and columns are separated by space)
A=importdata('sample.txt',' ',0);
Error using importdata (line 136) Unable to open file.
Can somebody suggest me why I am getting this error?
Thanks in advance.

Best Answer

The file isn't actually named 'sample.txt' or, more likely, it's not in the current working directory or on the matlabpath searched by Matlab.
Try
exist('sample.txt','file')
It'll undoubtedly return FALSE (0).
Or,
dir samp*.*
and see what files beginning w/ the string 'samp' are found in current directory.
Either use a fully-qualified file name or change to the directory as current or add the location to the matlabpath