finding peak to draw a smooth curve

조회 수: 2 (최근 30일)
Sowmya MR
Sowmya MR 2019년 8월 14일
답변: Star Strider 2019년 8월 14일
Hi All,
I have attached a plot (blue) in which i want to identify peaks (red circle) and draw a smooth curve with similar shape (black) joining the detected read peaks. Can someone please help me here?
Thanks
Sowmya

채택된 답변

Star Strider
Star Strider 2019년 8월 14일
Try this:
x = 0:10; % Create Data
y = rand(1,11); % Create Data
[pks,locs] = findpeaks(y); % Peaks ^ Location Indices
xi = linspace(min(x), max(x), 75); % Interpolation Vector
yi = interp1(x([1 locs end]), y([1 locs end]), xi, 'pchip'); % Interpolate
figure
plot(x,y)
hold on
plot(x(locs), y(locs), '^r')
plot(xi, yi, '-g')
hold off

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by