Using MacOS Catalina and can't import any file at all in MATLAB

조회 수: 14 (최근 30일)
Ida
Ida 2020년 11월 1일
댓글: Walter Roberson 2020년 11월 6일
I'm fairly inexperienced at Matlab and I'm not able to import the .xlsx or .txt files I need, whenever i try I'm just reciving errors such as line 198 and line 157 stating that Matlab is unable to find or open the files i try to import and that I should check the filename and file permissions. What i have tried/checked:
  • Updated Matlab to MATLAB_R2020b
  • Checked my preferences in Security and Privacy
  • data = readmatrix("filename.txt")
  • data = readatable('filename.xlsx')
  • exist('filename'), % I get 0
I really don't know what more I can try, but after searching around a bit it seems like more people are having problems with Matlab and OS not cooperating properly. Could anyone please help? Thank you.
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2020년 11월 1일
Can you show the complete error message?
Walter Roberson
Walter Roberson 2020년 11월 1일
편집: Walter Roberson 2020년 11월 1일
is it possible that you are getting information about the filename from the user, or by using dir(), and you are storing the name of the file in a variable named filename and then you are trying to read from "filename.txt" as a quoted string? If you have a variable that is holding the file name then you need to pass the variable to the reading routine instead of "filename"
For example
data = readmatrix(filename);
Or
ff = [filename '.txt'];
data = readmatrix(ff) ;

댓글을 달려면 로그인하십시오.

답변 (1개)

drummer
drummer 2020년 11월 1일
편집: drummer 2020년 11월 1일
Did you add the paths the files are placed so MATLAB can see them?
You can set the path by clicking in the refered button in environment section under Home tab.
Trying only to read the filename if it is not indicated to MATLAB where it is won't work.
Cheers
  댓글 수: 2
Lee Vousden
Lee Vousden 2020년 11월 6일
I have the same (or similar) problem under Windows. I copy the path from file manager, append \filename and put single quotes around it to get
data = readmatrix('C:\User\Documents\Results.txt')
but all I get back is
Error using readmatrix (line 157)
Unable to find or open 'C:\User\Documents\Results.txt')
Then I'm advised to check permissions and so on but it's just a txt file I made with notepad++ a few minutes before.
Walter Roberson
Walter Roberson 2020년 11월 6일
There is usually a username as part of MS Windows paths.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by