How can I connect the points in plot?

1 次查看(过去 30 天)
Babak
Babak 2013-6-11
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

回答(1 个)

Iain
Iain 2013-6-11
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)
  1 个评论
Babak
Babak 2013-6-11
No. It exploit my sinusoidal figure. It makes a vector to each point.My diagram is sinusoidal which is plotted by points.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by