Effacer les filtres
Effacer les filtres

Why Matlab doesn't see part of the excel sheet?

1 vue (au cours des 30 derniers jours)
CheshireM
CheshireM le 28 Oct 2021
I read multiple sheets excel file with following code:
Sheets = sheetnames(FileName);
for i = 1 : length(Sheets)
Name = Sheets{i};
data{i} = readmatrix(FileName,'Sheet',Name);
end
Each sheet looks the same: A1 cell is "Student ID" and A2 is "#" (ID number).
B1 is "Math grades", B2, B3, etc - grades (just numbers).
When I look at data cell array I see that some cells have this first row with ID, and some don't.
Any idea why is that?
Thank you!!
  2 commentaires
David Hill
David Hill le 28 Oct 2021
Can you attach your data file?
CheshireM
CheshireM le 28 Oct 2021

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 28 Oct 2021
"data" is a cell array because you used braces, not because that's what readmatrix() returns. Actually readmatrix() returns a numerical matrix - a double - which has no strings at all in it. And it's putting that numerical/double matrix into the ith cell of data.
If you want a cell array, so that it will have both numbers and strings, instead of a matrix, then use readcell() instead of readmatrix().
Please read the FAQ on cell arrays and you will understand better.

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by