how to find non zero maximum points(y_max with corresponding non zero x axis points ) of a plotted graph
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i have wrote a script to plot some graph but now i wanted to mark or create a table with non -zero maximum points of each segments from the graph ( y_max with corresponding non zero x axis points).how can i write code that it will omit the zero x axis points and take the ymax with non zeo x axis point .(basically i dont need the max y points at o th point)

1 commentaire
Réponses (1)
Abhishek Chakram
le 26 Sep 2023
Hi Linta Joseph,
It is my understanding that you are facing difficulty in getting the values of y where the corresponding x>0. Here is a sample code for the same:
x = [0 1 2 3 4 5 6 7 8 9 10];
y1 = [75 91 105 123.5 131 150 179 203 226 249 281.5];
y2 = [12 32 34 1 31 10 19 23 236 945 678];
y3 = [32 65 456 12 11 15 17 545 546 457 657];
% Enable hold on to plot multiple bar graphs in one graph
hold on;
bar(x, y1, 'b');
bar(x, y2, 'r');
bar(x, y3, 'g');
hold off;
% Get the values where x>0
y11 = y1(x>0);
y22 = y2(x>0);
y33 = y3(x>0);
% Find the maximum value of index-wise elements
segment_max = max([y11; y22; y33], [], 1)
In this example, the y values are extracted where x>0. The segment_max contains the ymax for each segment.
Best Regards,
Abhishek Chakram
0 commentaires
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!