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 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Dennis
Dennis le 22 Oct 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

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by