How to find both of the local minimums in this plot ?
2 views (last 30 days)
Show older comments
Hi All
just having the vectors of the axes , how can I find the minimums ?
2 Comments
dpb
on 7 Apr 2015
What does "just having the vectors of the axes" mean, precisely? If you don't have the y-axis data values that plotted the curve, you have nothing. Of course, if you do have the figure by having been sent it as a .fig file say, but not the data that drew it, you can obtain such by finding the handle for the line on the axes and querying it for the '[x|y]data' properties.
Accepted Answer
Image Analyst
on 7 Apr 2015
If you have the Signal Processing Toolbox, invert your data and call findpeaks().
y = max(y) - y;
[peaks, indexes] = findpeaks(y);
4 Comments
Image Analyst
on 7 Apr 2015
farzad, I don't know what you tried since you didn't attach your code. So I made a full demo:
s = load('y.mat')
y = s.weight;
s = load('x.mat')
x = s.D11;
% Plot original data.
subplot(1,2,1);
plot(x, y, 'b-', 'LineWidth', 3)
grid on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Flip the data.
yFlipped = max(y) - y;
% Plot flipped data.
subplot(1,2,2);
plot(x, yFlipped, 'b-', 'LineWidth', 3)
grid on;
[peaks, indexes] = findpeaks(yFlipped)
xPeaks = x(indexes)
% Indicate the peaks on the flipped graph
hold on;
plot(xPeaks, peaks, 'r*', 'LineWidth', 3, 'MarkerSize', 15);
% Go back to the unflipped plot and indicate them.
subplot(1,2,1);
hold on;
plot(xPeaks, y(indexes), 'r*', 'LineWidth', 3, 'MarkerSize', 15);
% Draw lines from lower axis to valleys
yl = ylim();
for k = 1 : length(peaks);
line([xPeaks(k), xPeaks(k)], [yl(1), y(indexes(k))], ...
'LineWidth', 3, 'Color', 'm');
end
dpb, it flips the data, not translates it. Though I agree, it could be done with -y instead of max(y)-y.
More Answers (0)
See Also
Categories
Find more on Spectral Estimation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!