MATLAB Answers

How to get matlab to read the code

조회 수: 27(최근 30일)
I have converted data from OnScale to matlab. I have been given a script which will read the data from this subfolder. The data loads in fine but I keep getting this error messages,
Error using load
Unable to read file 'C:\Users\User\Dropbox\My PC (LAPTOP-8G4JCC0U)\Documents\onscale1\2d_simple_array.mat'. No
such file or directory.
Error in example_import (line 15)
load(strcat('C:\Users\User\Dropbox\My PC
(LAPTOP-8G4JCC0U)\Documents\onscale',num2str(i),'\2d_simple_array.mat'));
All the files are in the same directory and folder as far as I can see, so maybe something needs changed in the code I have attahced screen shots of my code from line 15.
Thanks

채택된 답변

Walter Roberson
Walter Roberson 3 Mar 2021
Your code has
load(strcat('C:\Users\User\Dropbox\My PC (LAPTOP-8G4JCC0U)\Documents\onscale',num2str(i),'\2d_simple_array.mat'));
^^^^^^^^^^^
That num2str(i) is inserting a 1 onto the end of the directory name, giving you a directory name of onscale1 but your files are in a directory named onscale with no 1
  댓글 수: 3
Walter Roberson
Walter Roberson 3 Mar 2021
I don't really understand why that changes the directory by adding a 1 onto the end
Because that is what strcat does
i = 7;
strcat('Lucky number=', num2str(i))
ans = 'Lucky number=7'
You have the strcat() operation at the point that you are constructing the directory name, not at the point where you are constructing the file name.
This code was given to me
Rename your directory from
C:\Users\User\Dropbox\My PC (LAPTOP-8G4JCC0U)\Documents\onscale
to
C:\Users\User\Dropbox\My PC (LAPTOP-8G4JCC0U)\Documents\onscale1
and the code will work for the first iteration.
The code as written also expects directories onscale2, onscale3, onscale4, up to onscale16, each with a file 2d_simple_array.mat in it.

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by