MATLAB: Vector imbalance error in while loop

if statementstructuresvectorwhile loop

I am trying to plot based on a certain situation. In the first to situation (Beam. Load == 1 and Beam.Support == 1) and (Beam. Load == 1 and Beam.Support == 2), I need to create two sets of y values and two sets of x values and then join them together such that x1 is the x values and y is y values. When I run this script in MATLAB the other cases work, but not the one stated above. Instead MATLAB returns the error:
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in Beam_Deflection_GUI>process (line 395)
y1(i) = (F.*x.^2/6*E*I).*(3*a-x); % 0<x<a


Error while evaluating uicontrol Callback
Here is the Code:
I = Beam.Inertia;
a = Beam.Location;
F = Beam.Magnitude;
L = Beam.Length;
b = Beam.Length-Beam.Location;
x = linspace(0,Beam.Length);
o = Beam.Magnitude/Beam.Length; % Magnitude is them same as the force
y1 = zeros(1,100);
y2 = zeros(1,100);
x1 = zeros(1,100);
x2 = zeros(1,100);
i = 1;
Beam.x1 = x;
if Beam.Load == 1 % Referring to the point in the list during the selection
if Beam.Support == 1
while x(i) < a
y1(i) = (F.*x.^2/6*E*I).*(3*a-x); % 0<x<a
x1(i) = x(i);
i = i + 1;
end
while x(i) <= L && x(i) < a
y2(i) = (F.*a^2/6*E*I).*(3*x-a); % a<x<L

x2(i) = x(i);
i = i+1;
end
Beam.y1 = [y1, y2];
Beam.x1 = [x1, x2];
else % x.Support == 2
while x(i) < a
y1 = (F*b.*x/6*L*E*I).*(L^2-x.^2-b^2); % 0<x<a
i = i+1;
x1 = x(i);
end
while x(i) <= L
y2 = (F*b/6*E*L*I).*((L/b).*(x-a).^3+(L^2-b^2).*x-x.^3);% a<x<L
i = i+1;
x2 = x(i);
end
Beam.y1 = [y1, y2];
Beam.x1 = [x1, x2];
end
else % x.Load == 2
if Beam.Support == 1
Beam.y1 = (o.*x.^2/24*E*I).*(x.^2+6*L^2-4*L.*x);
else % x.Support == 2
Beam.y1 = (o.*x.^2/24*E*I).*((L^3-2*L.*x.^2)+x.^3);
end
end

Best Answer

You may have meant:
y1(i) = (F.*x(i).^2/6*E*I).*(3*a-x(i)); % 0<x<a
Otherwise you are trying to put numel(x) elements into a single element of y1.