Weird line on sine graph
5 views (last 30 days)
Show older comments
Rhiannon Elliott
on 16 Feb 2021
Commented: Rhiannon Elliott
on 16 Feb 2021
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)')

0 Comments
Accepted Answer
David Hill
on 16 Feb 2021
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)');
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!