Error using xlsread (line 129). File name must be a string or character vector.

20 visualizzazioni (ultimi 30 giorni)
I am getting this error when submitting my answer to Matlab Grader.
Error using xlsread (line 129)
File name must be a string or character vector.
Error in xlsxdatatostructurearray>dependentdata (line 151)
[num,txt,raw] = xlsread(CurrentSheet);
When I do class(CurrentSheet) it returns 'char'.
  1 Commento
Cameron Tiegs
Cameron Tiegs il 31 Mag 2020
Modificato: Cameron Tiegs il 31 Mag 2020
The contents of CurrentSheet is cycled through each excel file that begins with AerodynamicData. So for one instance CurrentSheet will have a value of, CurrentSheet = 'AerodynamicData_Cm_BodyFlap.xlsx'

Accedi per commentare.

Risposta accettata

Cris LaPierre
Cris LaPierre il 31 Mag 2020
What happens if you click "Run Function" instead of Submit?
Your code seems to run fine in MATLAB. I also created a problem in MATLAB Grader using the files you shared. It also ran without error. In fact, the only way I generate the exact same error message is if I do something like this:
[num,txt,raw] = xlsread(5);
When your function is assessed in MATLAB Grader, the code for calling the function can be different that what you see in the "Code to call your function" section (this section is so you can test that your function is working before submitting). Typically, the instructor will test the correctness of your function using different inputs. This seems to be the case under which you are getting an error.
Without more information about the actual test inputs, there is little we can do to help. I suggest reaching out to your instructor directly.

Più risposte (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov il 31 Mag 2020
Your codes are workign very well. You'd need to have all of your data files and scripts in one directory. That is it.

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by