MATLAB: Trying to create a new vector from 2 vectors.

MATLAB

Hello,
I have a routine below that reads in an excel file. The vector y is created. It then computes r from a function and from that y1 is computed.
I then want to create a new vector y2. This vector will contain the first 3 elements of vector y and the last 3 elements of vector y. The elements in between will come from y1.
I am getting an error
??? Error using ==> horzcat
CAT arguments dimensions are not consistent..
but the vectors y and y1 are the same size and direction.
When I type y(1:3), y1(4:end-3), y(end-2:end) separately into the command line I get the elements that I am expecting and when you sum their lengths together it equals the length of y and y1.
Would anybody know what is going wrong?
Thank you
sch_cycle=xlsread('C:\Autonomie practice\RW.xls','Input_data');
nrows = size(sch_cycle,1)-1;
x = sch_cycle(:,1);
y = sch_cycle(:,2);
h=3;
N= size(sch_cycle,1);
r=ksr(x,y,h,N)
y1=r.f';
y2 = [y(1:3) y1(4:end-3) y(end-2:end)];

Best Answer

y = y(:);
y1 = y1(:);
y2 = [y(1:3); y1(4:end-3); y(end-2:end)];