using find-command to find max or min value
1 view (last 30 days)
Moustafa Abedel Fattah on 26 Jun 2022
Please I need your help to estimate the value of min or max of abs(Y) and its corresponding (X) for attached curve (X versus X ) using (find)-command. In addition want plot a line of corresponding (X) and (Y).
Thanks in advance for all.
Star Strider on 26 Jun 2022
This is relatively straightforward. Use max with two outputs:
x = 0:13;
y = randi(25,1,14)/100;
[ymax,idx] = max(y)
plot([1 1]*x(idx), [min(ylim) ymax], '-r')
plot([0 x(idx)], [1 1]*ymax, '-r')
Experiment with your data.
More Answers (1)
Image Analyst on 26 Jun 2022
I prefer using the find function in combination to find max and min locations. The reason being if the max occurs at more than one location, max only gives you the location of the first one. I've asked them for many, many years to return the index(es) of all max in the vactor.
y = [1 3 2 3 0] % Max at index 2 and 4
[maxValue, indexes] = max(y) % Only gives you the one at index 2 not at 4.