How can I connect the points in plot?
1 view (last 30 days)
Show older comments
Hello everybody, I am writing some program which I have to use FOR loop for drawing the sine function.I would like to plot them continuously,I can't connect the points. Could you help me out?
Thanks.
f=50;
w=2*pi*f;
t1=0.05;
t2=0.1;
alfa=0.7;
for t=0:0.001:pi/15
if t-t1>=0
u1=1;
else
u1=0;
end
if t-t2>=0
u2=1;
else
u2=0;
end
ysag=(1-alfa*(u1-u2))*sin(w*t);
hold on
plot(t,ysag,'b.-')
end
0 Comments
Answers (1)
Iain
on 11 Jun 2013
To draw a line, you need to always supply two points.
Before the loop: t_prior = 0; ysag = 0;
Just before the end:
t_prior = t;
ysag_prior = ysag;
and plot:
plot( [t_prior t], [ysaq_prior ysag],'b')
(Do it with a solid line to start - to prove it works)
See Also
Categories
Find more on Surface and Mesh Plots 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!