MATLAB Answers

Tom
0

MATLAB can't find my file

Asked by Tom
on 12 Dec 2012
Latest activity Commented on by Alireza Kharazmi on 8 Aug 2016
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

  0 Comments

Sign in to comment.

Tags

Products

2 Answers

Walter Roberson
Answer by Walter Roberson
on 12 Dec 2012
 Accepted Answer

(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.

  7 Comments

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
on 28 Jul 2016
Instead of cd'ing around, you should use fullfile() to construct complete file names.
My apologies for late response, thank you very much for your help Walter. My problem is fixed now.

Sign in to comment.


Tom
Answer by 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
on 12 Dec 2012
Was there a hidden extension? Or was there a typo in the file name?

Sign in to comment.