简体   繁体   中英

Connect discrete points together in a plot using Matlab?

If I have the following figure :

在此处输入图片说明

created by the code :

for t=1:length(s)  % s is a struct with over 1000 entries
    plot(t,r1,'k'); % r1 = (0,100,150,170) + 1050
    plot(t,r2,'g'); % r2 = (0,300,350,370) + 1050
    plot(t,r3,'b'); % r3 = (0,200,250,270) + 1050
    plot(t,r4,'m'); % r4 = (0,1000,1250,1500) + 1050
    plot(t,max,'r'); % max = 2000
end

Each dot is actually propagating from 1050 to their current value. But you can't see it this way and hence why I would like for a line to be drawn to connect them all.

How can I connect discrete points of the same line together ?

Does this give the result that you want?

for t=1:length(s)  % s is a struct with over 1000 entries
    a(t,:)=r1; % r1 = (0,100,150,170) + 1050  
end
plot(a)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM