Plotting specific range - amplitude peak

조회 수: 12 (최근 30일)
Kaique Silva
Kaique Silva 2015년 6월 19일
댓글: Star Strider 2015년 6월 28일
Hi, I have this data, and what I am trying to do is plot just the first peak (shown inside the rectangle) of the amplitude plot. I work with different data, so I am looking for a way to do it automatically. Any ideas?
It is more like 'giving a zoom' in that specific range. I am using the following the code to plot the data.
format long g
fid2 = fopen('FarReceiver.csv');
if fid2 > 0
data = textscan(fid2,'%s %s %f %f %f','Delimiter',',','HeaderLines',1);
fclose(fid2);
end
Timestamp2 = strcat(data{:,2});
Timeformat2=datenum(Timestamp2,'HH:MM:SS.FFF');
ConvertTime2 = (Timeformat2 * 86400000);
b = ConvertTime2(1);
TimestampNum2 = (ConvertTime2 - b);
amplitude2 = [data{:,5}]';
Amplitude_max2 = max(abs(amplitude2));
ampfar = (amplitude2/Amplitude_max2);
z = mean(ampfar);
amp2 = (ampfar - z);
plot(TimestampNum2, amp2)
Thank you very much!

채택된 답변

Star Strider
Star Strider 2015년 6월 19일
If you have the Signal Processing Toolbox, use the findpeaks function.
This is written to be specific to the data you attached, so I don’t know how well it would generalise to your other signals. It is a way to automate your isolation of the first impulse.
This replaces your plot call in your code:
[Pks,Locs] = findpeaks(amp2, 'MinPeakHeight',0.2, 'MinPeakDistance',50);
figure(1)
plot(TimestampNum2, amp2)
hold on
plot(TimestampNum2(Locs(1)), Pks(1), '^r')
hold off
figure(2)
plot(TimestampNum2(Locs(1)-5:Locs(2)-5), amp2(Locs(1)-5:Locs(2)-5))
grid
You may need to experiment with it to get the result you want.
  댓글 수: 4
Kaique Silva
Kaique Silva 2015년 6월 28일
Thank you very much. Have a good day!
Star Strider
Star Strider 2015년 6월 28일
As always, my pleasure.
You, too!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by