Reputation: 173
The code gives me the error
Dimensions of arrays being concatenated are not consistent.
Why is that? I have created a cell array with different string cells with different length, was not a problem as this for example works.
test = {'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'b' 'a' 'ddddddddddasdfasdfasdfadsfb' 'a' 'bdd'}
Questions = {'Constant' 'The teacher shows an interest in every student''s learning'
'There is noise and disorder' 'Number of class periods per week in the test language'
'Number of class periods per week in mathematics' 'Number of class periods per week in science'
'Number of books at home' 'Having Desktop Computer' 'Having a Notebook' 'Having a Tablet' 'Having a Console' 'Having an eReader'};
Upvotes: 1
Views: 58
Reputation: 125854
You have to put ellipses at the end of each line so it continues the horizontal concatenation properly:
Questions = {'Constant' 'The teacher shows an interest in every student''s learning' ...
'There is noise and disorder' 'Number of class periods per week in the test language' ...
'Number of class periods per week in mathematics' 'Number of class periods per week in science' ...
'Number of books at home' 'Having Desktop Computer' 'Having a Notebook' 'Having a Tablet' 'Having a Console' 'Having an eReader'};
Without an ellipsis, MATLAB interprets the move to the next line as if you put a semicolon (i.e. vertical concatenation), placing subsequent values in the next row. In your case, you end up with rows of different lengths being vertically concatenated, hence the dimension mismatch error.
Upvotes: 4