MATLAB: Weird line on sine graph

figureplotsin

Hi! I was wondering if anyone had any ideas as to why there is a horizontal line plotted on the figure below? I'm struggling to figure out why! I checked the variables stored in the x vector, and nothing was out of the ordinary.
I'm hoping I have just missed something obvious, perhaps with my time column vector?
%Defining the time column vector, as required
t = [0:0.001:2,1]';
x = [cos(2*pi.*t) sin(2*pi.*t)];
plot(t,x)
xlabel('time')
ylabel('x')
title('Exercise 2 figure')
legend('cos(2*pi*t)','sin(2*pi*t)')

Best Answer

t = 0:0.001:2;
x = [cos(2*pi.*t); sin(2*pi.*t)];
plot(t,x(1,:),t,x(2,:));
xlabel('time');
ylabel('x');
title('Exercise 2 figure');
legend('cos(2*pi*t)','sin(2*pi*t)');