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

20 ビュー (過去 30 日間)
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 件のコメント
Cameron Tiegs
Cameron Tiegs 2020 年 5 月 31 日
編集済み: Cameron Tiegs 2020 年 5 月 31 日
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'

サインインしてコメントする。

採用された回答

Cris LaPierre
Cris LaPierre 2020 年 5 月 31 日
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.
  1 件のコメント
Cameron Tiegs
Cameron Tiegs 2020 年 5 月 31 日
I get no errors when I "Run Function". Thank you, I have emailed my lecturer now.

サインインしてコメントする。

その他の回答 (1 件)

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

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by