Keep getting this error code: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
2 ビュー (過去 30 日間)
古いコメントを表示
My task is to ask the user for the number of sheets and set up a for loop. Once in the loop, use xlsread to read the data from the desired sheet (there are 5 sheets in the excel file which represent 5 students' name, each of their grades, credits hours for each of the grades and majors). All of these information are on each of the 5 sheets in the excel file.
These are my code. numofsheets = input('Please input the number of students.'); for i=1:numofsheets [numericalData(i)]=xlsread('gradeData.xlsx',i); [textData(i)]= xlsread('gradeData.xlsx',i); end I keep getting the error message saying that Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. Please help.
0 件のコメント
採用された回答
Dennis
2018 年 10 月 22 日
The left side is a single field in a matrix numericalData(i), this could for example be a number or a string. The right side is the content of your excel sheet. This might be alot of numbers and strings.
To fix this you should use cells instead. In addition both of your xlsread calls will return only the numerical data.
numofsheets = input('Please input the number of students.');
for i=numofsheets:-1:1
[numericalData{i},textData{i}]=xlsread('gradeData.xlsx',i);
end
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!