Variable TempData must be of size [25 33]. It is currently of size [31 24]. Check where the variable is assigned a value.
2 次查看(过去 30 天)
显示 更早的评论
% read excel file
TempData = readmatrix ("Clemson_Temp.xlsx");
% trim TempData
TempData=TempData(2:end,3:end);
% calculate monthly maximum
MonthMax=max(TempData(1:2:24,:)')
% calculate monthly minimum
MonthMin=min(TempData(2:2:24,:)')
The variable TempData needs to be [25 33] and is [31 24] how can I change it to be so?
0 个评论
采纳的回答
Walter Roberson
2020-7-3
You cannot do that.
After reducing by 1 row, your data ended up with 31 rows. Therefore it had 32 rows to start.
After reducing by 2 columns, your data ended up with 24 columns. Therefore it had 26 columns to start.
Suppose we take
TempData = readmatrix ("Clemson_Temp.xlsx") .'; %NOTICE THE TRANSPOSE
then TempData would be 26 rows and 32 columns (after the transpose.)
You can remove one row from that,
TempData = Tempdata(32:end,:);
and the result would be 25 rows and 32 columns. Which is close, but you need it to be 25 rows and 33 columns. You cannot "invent" the missing 33rd entry.
I suspect that the input had 33 rows but that the first row was interpreted as being a header and so was discarded by readmatrix. If you have reason to believe that the first row is valid data, then try
TempData = readmatrix("Clemson_Temp.xlsx", 'NumHeaderLines', 0) .'; %NOTICE THE TRANSPOSE
TempData = TempData(2:end,:);
2 个评论
Walter Roberson
2020-7-3
After you do
TempData = readmatrix ("Clemson_Temp.xlsx");
then what is size(TempData) ?
Year =sprintf("Clemson_Temp.xlsx");
That line seems unlikely to be correct.
更多回答(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!