Plotting Data Points with Lines to Indicate Unchanging Conditions Over Time

2 views (last 30 days)
I wish to plot a time series for some data that has horizontal/vertical lines connecting them to indicate that once a value was selected, it remains constant over time until the next point is selected. I thought of one way to do this, but it is extremely complicated and would take way more time than it's worth to implement. Does anyone know of a simple method to do this or maybe a Matlab plotting function that can do this?
Visual Example:
Left side: Data plotted Right side: Data plotted with connecting lines

Accepted Answer

William Rose
William Rose on 22 Feb 2023
stairs(x,y)
I use it for heart rate data all the time, since, once you have a rate estimate from detecting the second R wave in a recording, you do not have another HR estimate until the next R wave is observed.
  4 Comments
Steven Lord
Steven Lord on 22 Feb 2023
FYI, since I think a lot of users don't know about this, take a look at the Plots tab of the toolstrip. It shows small thumbnails of many of the different visualization functions in MathWorks products. If one looks similar to what you want you can see the name of the function used to create that type of plot under the thumbnail.
If you have selected a particular variable in the Workspace window you can even limit the plots shown to only those that can be created from that data and can click on the thumbnail to create a plot for that specific data.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!