How to plot the variations of the maximum and minimum on 2 separate diagrams

Hi everyone,
I obtained with the following code the plot for each image of the maximum and minimum distance (I have attached for example 3 plots but in reality there are more)
[max_value max_index]=max(mean(all_maxDist/distance_mm))
[min_value min_index]=min(mean(all_maxDist/distance_mm))
m= plot((max_index),max_value , 'ro', 'MarkerSize', 12, 'LineWidth', 2);
% Draw a line from the x-axis up to the max.
line([(max_index), (max_index)], [0,max_value ], 'Color', 'r', 'LineWidth', 2);
n=plot((min_index),min_value , 'ro', 'MarkerSize', 12, 'LineWidth', 2);
% Draw a line from the x-axis up to the min
line([(min_index), (min_index)], [0,min_value ], 'Color', 'r', 'LineWidth', 2);
Now ,I would like to get 2 graphs separately (one for the maximum and one for the minimum) that show me the variations that the maximum and the minimum undergo for each iteration (eventually finding a sort of square wave)

8 Comments

@Francesco Muoio It is extremely rude to edit away your question once you have received an answer. I will restore your question and your comment from Google cache.
Rik unfortunately the question was not clear!!
And editing away everything made it more clear?
If you have the underlying data, why don't you use that? Editing away your question does not motivate people to help you. Remember that people are helping you here as a hobby.
You should clearly state what data you have at the start, and what data you want to have in the end. And you should put back the attachments.
Rik ,I want to take all the maximum indices and maximum values ​​obtained for each iteration
(see attached plots)and plot them on a final chart to see the trend(these points must be joined by a line)
I want to do the same for the minimum index and minimum value and plot it on another single graph.
I hope you can help me!!
Do you only have the images, or do you have the data that was used to plot them? And from these 3*2 values, what output would you want?

Sign in to comment.

Answers (1)

Read about the function stem
x = rand(1,10) ;
[val1,idx1] = min(x) ;
[val2,idx2] = max(x) ;
stem([idx1 idx2],[val1 val2])
xlim([0 10])

1 Comment

KSSV for each iteration I want you to describe me a real trend of the variations and not a stem.
In the end I want to get only one final graph for maximum variations and only one graph for minimum variations.

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Asked:

on 9 Feb 2021

Commented:

on 10 Feb 2021

Community Treasure Hunt

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

Start Hunting!