Why Matlab doesn't see part of the excel sheet?
1 次查看(过去 30 天)
显示 更早的评论
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!!
回答(1 个)
Image Analyst
2021-10-28
"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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!