identify a corresponding value

1 view (last 30 days)
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)

Accepted Answer

Image Analyst
Image Analyst on 29 Feb 2020
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 Comments
Image Analyst
Image Analyst on 29 Feb 2020
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);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!