MATLAB: Is an extra line being plotted

lineloopplot

Hello,
I have been trying to display the deflection and displacement of beams within a building. Currently, I am having an issue from within my loop which plots the displacement of each floor.
As you can see from the plot below, I have a red horizontal line from (0,0) to(2,0). Why is this? I think I have done something wrong in my "Displacement" loop but I am not sure
numFlr=2
Phi_EigVec=[1 3;2 -3;]
y1=zeros(numFlr,1);
y2=zeros(numFlr,1);
x1=zeros(numFlr,1);
x2=Phi_EigVec(:,1);
%Displacement
hold on
for i=1:numFlr
y1(i)=i
y2(i)=i
A = [x1(:) x2(:)]; B = [y1(:) y2(:)];
plot(A.',B.','r')
end
%Beam Deflection
AZero=[0]
BZero=[0]
AEven=A(:,2:2:end);
BEven=B(:,2:2:end);
AFull=[AZero,AEven']
BFull=[BZero,BEven']
plot(AFull.',BFull.','g')
%Vertical Line
y=numFlr
line([0,0],[0,y])
%Axis
axis([-5 5 -1 5])

Best Answer

More like this, I think:
numFlr=2;
Phi_EigVec=[1 3;2 -3;];
y1=zeros(numFlr,1);
y2=zeros(numFlr,1);
x1=zeros(numFlr,1);
x2=Phi_EigVec(:,1);
%Displacement
hold on
for i=1:numFlr
y1(i)=i;
y2(i)=i;
end
A = [x1(:) x2(:)]; B = [y1(:) y2(:)];
plot(A(1,:),B(1,:),'r',A(2,:),B(2,:),'r')
hold on
%Beam Deflection
AZero=[0];
BZero=[0];
AEven=A(:,2:2:end);
BEven=B(:,2:2:end);
AFull=[AZero,AEven'];
BFull=[BZero,BEven'];
plot(AFull.',BFull.','g')
%Vertical Line
y=numFlr;
line([0,0],[0,y])
%Axis
axis([-5 5 -1 5])