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!