Gaussian shape for 'findpeaks' function?
4 views (last 30 days)
Show older comments
Hello everyone, probably this is an easy question…. for the ‘findpeaks’ function how can I do its plot looks like a Gaussian shape and modify the markers style? Thanks. Here is the code:
ax17=subplot(1,2,2);
[pks4,locs4,widths4,proms4] = findpeaks(pws4(:,end),y,'MinPeakHeight',25);
findpeaks(pws4(:,end),y,'Annotate','extents','WidthReference','halfprom'); % Gaussian shape? how ??
text(locs4+0.5,pks4,num2str((1:numel(pks4))'));
legend('Filtered Data','Peak','Prominence','Width','FontSize',5);
ax17.YAxisLocation = 'right';
ax17.XDir = 'reverse';
ax17.XGrid = 'on';
ax17.YGrid = 'off';
title ('Time (20:30 - 21:00)');
ylabel('Layering identification','FontSize',9,'FontName','Arial','color','default');
xlabel('Altitude/km','FontSize',9,'color','default');
yticklabels('');
xlim(ax17,[75 95]);
ylim(ax17,[15 19]);
camroll(-90)
%typo edited
7 Comments
Mathieu NOE
on 1 May 2021
hello
there are some points to be clarified :
- pws4 has 7 columns , but seems you are only interested in the last column - correct ? : pws4(:,end)
- this line does not work as the data has no peak above 25 (max value is about 22)
[pks4,locs4,widths4,proms4] = findpeaks(pws4(:,end),y,'MinPeakHeight',25);
- the next line works but I don't understand what you are trying to achieve - what does the gaussian shape stuff mean ? you would like to fit a king of gaussian pulse to the data ? and take the gaussain peak value coordinates ?
- basically this is what this line gives :
but then I wondered if the question was about a technique to shape the data to give them a king of gaussian shape
if that is the question see the output of these two smoothing filters; the sgolay performs better IMHO
code :
% smoothing filters (makes the data have a pseudo gaussian shape)
figure(2)
tmp = pws4(:,end);
tmps = medfilt1(tmp, 25,'truncate');
tmpss = sgolayfilt(tmp,2,71);
plot(y,tmp,y,tmps,y,tmpss);legend('Raw','Smoothed medfilt1','Smoothed sgolayfilt');
title('Data Smoothed');
Answers (0)
See Also
Categories
Find more on Spectral Estimation 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!