Why the exact same command (xlswrite) work with some varible but not others of the same kind?
16 views (last 30 days)
Show older comments
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 !
1 Comment
Image Analyst
on 7 Sep 2012
It has nothing to do with xlswrite, but has to do with the concatenation with the brackets.
Accepted Answer
Image Analyst
on 7 Sep 2012
Edited: Image Analyst
on 7 Sep 2012
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);
More Answers (1)
Azzi Abdelmalek
on 7 Sep 2012
Edited: Azzi Abdelmalek
on 7 Sep 2012
because your min strings are not same length
char(min1,min2,min3)
or
strvcat(min1,min2,min3)
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!