MATLAB: The exact same command (xlswrite) work with some varible but not others of the same kind

xlswrite

As in title, when using
xlswrite('Max.xls',[Max1; Max2; Max3; Max4; Max5; Max6; Max7; Max8; Max9; Max10])
everything's fine. a Max.xls is generated. BUT, when using
xlswrite('min.xls',[min1; min2; min3; min4; min5; min6; min7; min8; min9; min10])
an "Error using vertcat CAT arguments dimensions are not consistent." pops up..
Max1-10 and min1-10 are both texts.
Can anyone explain this? Doesn't really make sense to me..
Thank you !

Best Answer

Character arrays have to be rectangular. So you can't do this ['123', '12345678']. If your texts are different sizes, then you need a cell array. You need a cell array anyway, otherwise xlswrite will put one only character into each Excel cell, instead of putting the whole string into a single cell. So try this:
ca = {min1; min2; min3; min4; min5; min6; min7; min8; min9; min10};
xlswrite('min.xls', ca);