MATLAB Answers

MATLAB can't find my file

129 views (last 30 days)
Tom on 12 Dec 2012
I'm trying to read in an excel spreadsheet and I can't get it to do it.
I put the spreadsheet in the MATLAB home directory, then I put this: -
M = xlsread('Psych_anon_mine.xlsx');
And I get the error message: -
??? Error using ==> xlsread at 214 XLSREAD unable to open file Psych_anon_mine.xlsx. File /Users/Tom**********/Documents/MATLAB/Psych_anon_mine.xlsx not found.
(The stars are just my last name)
Error in ==> Ass_2_data_A at 3 M = xlsread('Psych_anon_mine.xlsx');
Any help would be greatly appreciated


Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 12 Dec 2012
(Looks like you are using OS-X)
At the MATLAB command prompt, try
!ls ~/Documents/MATLAB/Psych_anon*
and see if it finds the file. Perhaps there is a hidden extension.


Show 4 older comments
Alireza Kharazmi
Alireza Kharazmi on 28 Jul 2016
Sorry, I am not sure if I answered your question properly. I am confused now. I am using three open file with three different push buttons. I am starting from the same directory where .m file is placed. The first push button is uigetfile and then cd command to get into the directory of interest and then importdata some data. Second push buttons is another uigetfile and then importdata some other files. These two steps are okay. The third push button is a uigetfile but the file of interest is inside another folder in the current directory. At this point I get this error "Unable to open file.".
Walter Roberson
Walter Roberson on 28 Jul 2016
Instead of cd'ing around, you should use fullfile() to construct complete file names.
Alireza Kharazmi
Alireza Kharazmi on 8 Aug 2016
My apologies for late response, thank you very much for your help Walter. My problem is fixed now.

Sign in to comment.

More Answers (1)

Tom on 12 Dec 2012
Yes thanks that worked. I just copied and pasted the address from that and it's working now. Many thanks.

  1 Comment

Walter Roberson
Walter Roberson on 12 Dec 2012
Was there a hidden extension? Or was there a typo in the file name?

Sign in to comment.

Sign in to answer this question.



Translated by