Why does the CAT function return error when attempting to concatenate a cell array with an empty vector in MATLAB 7.0 (R14)?

When, I try to concatenate a cell array with an empty array in MATLAB 7.0 (R14):
a = {'123', 'qwe', 'asd'};
x = [];
cat(1, a, x)
I receive the following error:
??? Error using ==> cat
The following error occurred converting from double to cell:
Error using ==> cell
Size vector must be a row vector with integer elements.

 Accepted Answer

This bug has been fixed in MATLAB 7.0.4 (R14SP2). If you are using a previous version, read the following:
There is a bug in MATLAB 7.0 (R14) that affects the way MATLAB handles empty arrays. To work around this issue, convert "x" to a cell array.
a = {'123', 'qwe', 'asd'};
x = [];
cat(2, a, {x})

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!