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!