MATLAB: Integers can only be combined with integers of the same class, or scalar doubles

errorinteger

OK here is my assignment prompt: The test suite workspace has two variables A and B described as follows:
The variable A is a 6-element row vector of random integers between 0 and 20. The variable B is a 10-element column vector of random integers between 0 and 50. Write a script that uses A and B to generate the vectors below and assign to the indicated variable names.
Generate a vector named ABrow that is a 16-element row vector consisting of the elements of A followed by the elements of B. Generate a second vector named BAcol that is a 16-element column vector consisting of the elements of ABrow in reverse order. Generate a third vector named FirstHalfA_LastHalfB that is an 8-element row vector consisting of the first 3 elements of A followed by the last 5 elements of B .
And here is my code.
% Declare row vector of length 6 with random values upto 20
A = round(rand(1,6)*20)
% Declare columnvector of length 10 with random values upto 50
B = round(rand(10,1)*50)
%concatnate A and B into new row vector
ABrow=[A, B']
%concatnate A and B into new column vector
BAcol=(fliplr(ABrow))'
%concatnate 3 elements of A and last 5 elements of B into new row vector
FirstHalfA_LastHalfB=horzcat(A(1:3),B(6:10)')
it works, but I cannot get my program to be accepted because I keep getting the error about integers. Can anyone explain to me where my syntax error is? Thanks in advance!

Best Answer

ok apparently this code works but doesnt make any sense to me. Thanks for the help
% Declare row vector of length 6 with random values upto 20
A = round(A)
% Declare columnvector of length 10 with random values upto 50
B = round(B)
%concatnate A and B into new row vector
ABrow=horzcat(A,B')
%concatnate A and B into new column vector
BAcol=(fliplr(ABrow))'
%concatnate 3 elements of A and last 5 elements of B into new row vector
FirstHalfA_LastHalfB =[A(1:3),B(6:10)']