简体   繁体   中英

How to draw a jagged line?

How can you draw a jagged line in matlab? The graph will be like a saw, the slope is same but peaks are different.

For example:

Peak #   Start        End
1        (0.2,2.2)    (1.5,0)
2        (1.5,3)      (3.27,0)
3        (3.27,1.2)   (3.98,0)
etc.

Just use plot with the x and y coordinates of your points:

x = [0.2 1.5 1.5 3.27 3.27 3.98];
y = [2.2 0 3 0 1.2 0];
plot(x, y)

Unless you don't want the vertical lines? You can do it like this:

x = [0.2 1.5 nan 1.5 3.27 nan 3.27 3.98];
y = [2.2 0 nan 3 0 nan 1.2 0];
plot(x, y)

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