Error trying to load a file in MATLAB Grader

5 ビュー (過去 30 日間)
William Stuckey
William Stuckey 2020 年 1 月 28 日
コメント済み: William Stuckey 2020 年 1 月 31 日
I'm trying to load an Excel file (one column of numbers) in a MATLAB Grader script and getting an "Error using load" that says, "Number of columns on line 2 of ASCII file NavyData.xlsx must be the same as previous lines." I have no idea how to fix that error, because I don't know what it even means. Any suggestions?
  2 件のコメント
Geoff Hayes
Geoff Hayes 2020 年 1 月 28 日
William - can you use load with an Excel file (see load filename input parameter)? Why not convert the Excel file into an ASCII text file and try that instead?
William Stuckey
William Stuckey 2020 年 1 月 28 日
That worked, thnx!

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

回答 (1 件)

Cris LaPierre
Cris LaPierre 2020 年 1 月 30 日
It depends on what the end task is you are trying to achieve, but my recommendation would be to use readtable.
  6 件のコメント
Cris LaPierre
Cris LaPierre 2020 年 1 月 31 日
One thing that might help is the example problems that come with MATLAB Grader.
When you create a new problem, you are presented with what we call the problem chooser. There, you will see several tiles. Under the "Sample Problems from MathWorks" is a tile called "Getting Started with MATLAB Grader" (there are several others organized by topics such as Intro to Programming, Numerical Methods, Dynamics, System Dynamics and Controls, etc. If you don't see them but would like access, contact customer support to submit a request. They are free but access is restricted to instructors).
As the title suggests, these problems demonstrate how to accomplish various tasks. The best way to see what problem does what is to look at the table at the very end of the Teaching with MATLAB course. I'd point out these two problems in particular.
  • Analysis of stress-strain data. This uses readtable to load a *.xlsx file into the workspace.
  • Determine the drag coefficient by fitting a polynomial to velocity-force data. This uses readtable to load a *.csv file into the workspace.
Hopefully these help you. There are extra comments added to some of the assessment tests to explain what is being done.
William Stuckey
William Stuckey 2020 年 1 月 31 日
Thnx very much, Cris!

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

コミュニティ

カテゴリ

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