Continuous execution of vertical line for set of data

2 views (last 30 days)
Sam
Sam on 12 Mar 2021
Answered: Steven Lord on 12 Mar 2021
I'm new to Matlab
I want to plot a vertical line at specific values which I have stored in a variable, "HR"
For some data sets, there are several values within the variable and it would take a lot of time to plot a vertical line at each value.
Can someone help me write a code that continues to execute plotting this vertical line through the entire data set?
Example:
In the variable "HR" I have stored all of the values below. I want to plot a vertical line at each of these values. How would I go about writing a code or iterative loop to do this until it has plotted lines at each of these points and finished the data set?
0.340000000000000
0.980000000000000
4.65900000000000
5.24100000000000
38.8100000000000
39.4390000000000
239.070000000000
302.428000000000
309.415000000000
309.994000000000
312.011000000000
312.596000000000
313.162000000000
528.814000000000
926.693000000000
932.091000000000
935.019000000000
1033.03500000000
1055.55600000000
1211.96700000000
1422.35500000000
1462.23100000000
1468.41100000000
1468.99900000000
1469.61400000000
1472.49600000000
1473.09200000000
1913.67000000000
1933.99300000000
1934.57900000000
1935.12900000000
2000.45700000000
2004.35200000000
2004.93800000000
2304.14700000000
2304.73300000000
2556.99300000000
2835.84100000000
2840.34700000000
2847.08800000000

Accepted Answer

ANKUR KUMAR
ANKUR KUMAR on 12 Mar 2021
"I want to plot a vertical line at each of these values. ". The array you provided is 1D array. You will get 1 line plot out of these array.
A=[0.340000000000000
0.980000000000000
4.65900000000000
5.24100000000000
38.8100000000000
39.4390000000000]
plot(A)
Are you trying to plot multiple line in the plot out of this data?
What is the dimension size of the array?
  5 Comments
Sam
Sam on 12 Mar 2021
Thank you so much Ankur. I appreciate your help. I'll try this.

Sign in to comment.

More Answers (1)

Steven Lord
Steven Lord on 12 Mar 2021
It's not clear to me exactly what type of graphic you're trying to plot, but I think the stem and xline functions may be of use to you. Alternately, open the Plots tab on the Toolstrip. Click the small downward-pointing triangle in the Plots section of that tab and look for a thumbnail that appears similar to the type of plot you want to create. From there you can determine the specific plotting function used to create that type of plot (its name is below the thumbnail) and read its doc page to learn how to use it. You can even create the plot from the thumbnail if you have your data selected in the Workspace window.

Community Treasure Hunt

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

Start Hunting!

Translated by