필터 지우기
필터 지우기

identify a corresponding value

조회 수: 5 (최근 30일)
Ahmed Alalawi
Ahmed Alalawi 2020년 2월 29일
댓글: Image Analyst 2020년 2월 29일
Hello there,
I have three different signals (1,2,3)
I have identified the peaks values and locations in singal number 1 (blue color).
How can I idenitified the corresponding value of exact location in signals number 2 and 3?
I attached the data and the picture.
Could anyone provide me with the code please?
Thanks
I used this code:
figure (1)
plot (Data (:,1), Data (:,(2)), "b")
hold on
plot (Data (:,1), Data (:,(3)), "g")
hold on
plot (Data (:,1), Data (:,(4)), "r")
hold on
legend({'1','2', '3'},'Location','southwest')
hold on
hold off
[pks,locs] = findpeaks((Data (:,(2))), Data (:,1), 'MinPeakHeight',20, 'MinPeakDistance',1)

채택된 답변

Image Analyst
Image Analyst 2020년 2월 29일
Try this:
fullFileName = fullfile(pwd, 'data.mat');
s = load(fullFileName)
Data = s.Data_head;
hFig = figure
plot (Data(:,1), Data (:,2), "b", 'LineWidth', 2)
hold on
plot (Data(:,1), Data (:,3), "g", 'LineWidth', 2)
plot (Data(:,1), Data (:,4), "r", 'LineWidth', 2)
legend({'1','2', '3'},'Location','southwest')
hold off
grid on;
hFig.WindowState = 'maximized'; % Later versions of MATLAB only.
% Data(:, 1) are the x values.
% Get the peaks for y1:
[peakValues1, peakIndexes1] = findpeaks(Data(:,2), 'MinPeakHeight',20, 'MinPeakDistance',3);
% Get the peaks for y2:
[peakValues2, peakIndexes2] = findpeaks(Data(:,3), 'MinPeakDistance',3);
% Get the peaks for y3:
[peakValues3, peakIndexes3] = findpeaks(Data(:,4), 'MinPeakDistance',3);
  댓글 수: 2
Ahmed Alalawi
Ahmed Alalawi 2020년 2월 29일
Thanks for the quick response.
What I meant is, based on the peak value in the blue line, I need to identify the corresponing values in the other lines (red and green)? They do not have to be peaks in the red and blue, just the values.
Please see the attached picture for clarification.
Image Analyst
Image Analyst 2020년 2월 29일
You can just use the same indexes you got for the one signal, peakIndexes2, for all other signals. Do this:
% Get the peaks for y2:
peakValues2 = Data(peakIndexes2, 3);
% Get the peaks for y3:
peakValues3 = Data(peakIndexes2, 4);

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

추가 답변 (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