Flipping y-axis of findpeaks-plot
Show older comments
Hi!
To find minima-values of an array I multiplied my array with -1 and used findpeaks. To graphically show the minimas I want to reverse the findpeaks-plot but can't figure out how. Any suggestions?
E_bat3 = E_bat2.*(-1);
findpeaks(E_bat3(winter_hours)) %Graph I want to flip.
Thanks!
Accepted Answer
More Answers (2)
Don't you just want to negate the peak amplitude results rather than flip?
2 Comments
Nils Norlander
on 9 Mar 2017
Edited: Nils Norlander
on 9 Mar 2017
Adam
on 9 Mar 2017
But if they are minima then they will be larger as an absolute value than those around them so how can you display them still as minima if you plot the result as positive only?
I guess if you really want to do that then you need to subtract from whatever the largest absolute value in the results is.
Greg Dionne
on 9 Mar 2017
Edited: Greg Dionne
on 9 Mar 2017
I think Star Strider's answer is the right approach, but if you prefer the graphical 'look and feel' of the FINDPEAKS plot, then try this:
load mtlb
findpeaks(mtlb,Fs,'MinPeakProminence',1);
figure
findpeaks(-mtlb,Fs,'MinPeakProminence',1);
set(gca,'YDir','reverse');
set(findobj(gca,'Tag','Peak'),'Marker','^');
set(gca,'YTickLabel',cellfun(@(x)num2str(-str2num(x)),get(gca,'YTickLabel'),'UniformOutput',false))
2 Comments
Nils Norlander
on 9 Mar 2017
Greg Dionne
on 15 Mar 2017
Yes, that should work. FINDPEAKS expects vector input for Y. So in your case you could do findpeaks(-y, a) just like you did before, but then do the graphics commands above. I think they'll work no matter what input you have (so long as you actually have peaks). Otherwise, finding the 'peak' tag will fail because no peaks will actually be plotted.
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!