MATLAB: Variable TempData must be of size [25 33]. It is currently of size [31 24]. Check where the variable is assigned a value.

changeconvertvariables

% 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?

Best Answer

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,:);