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 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rachel Barbera
el 22 de Oct. de 2018
Respondida: Dennis
el 22 de Oct. de 2018
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 comentarios
Respuesta aceptada
Dennis
el 22 de Oct. de 2018
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!