I have a table with 5 columns and 100000 values (ECG and PPG signals). I need to find peaks of the signal starting from a value on the x axis (x_ECG_IV(i)) inside a range of 40 values. My idea is to use a for loop like this:
for i=1:length(peaks_ECG_IV)
A=x_ECG_IV(i) - 20*Tc :Tc: x_ECG_IV(i) + 20*Tc;
if x_ECG_IV(i) + 20*Tc < x_ECG_IV(length(peaks_ECG_IV)) && x_ECG_IV(i) - 20*Tc > x_ECG_IV(1)
[y_i,x_i] = findpeaks(DatiECGPPG.ECGLeadIV,A);
end
The problem is that A, array of 40(41 actually) values in which i need to find the peak for each x_ECG_IV(i), has not the same dimension of "DatiECGPPG.ECGLeadIV", which is the whole signal. How can i find the corresponding y value to the A interval?

 Réponse acceptée

Star Strider
Star Strider le 16 Fév 2023

1 vote

It would help to have the data, and a clearer description of what you want to do.
The findpeaks function does not have to have its inputs ‘windowed’ by time limits in order to find the appropriate peaks. Just give it each column in turn, and provide it with appropriate name-value pair arguments. My favourite is ‘MinPeakProminence’ since it will find the larger peaks and ignore the smaller peaks, and will even work correctly with signals with varying baselines.
I would do something like this (assuming the first column is the time vector):
T1 = readtable('YourTable.txt')
p = [ ... ]; % Prominence Vector For Each Column
for k = 2:size(T1,2)
[pks,locs] = findpeaks(T1{:,k}, 'MinPeakProminence', p(k));
pksc{k-1,:} = pks;
locsc{k-1,:} = locs;
end
Then process them afterwards. The ‘locsc’ values will index into the time vector and all the other vectors for each signal (matrix column or table variable). It is likely straightforward to determine the corresponding intervals.
.

4 commentaires

Matteo Svaldi
Matteo Svaldi le 16 Fév 2023
I'll add some context: the ECG signal has been filtered in order to find the peaks and peaks location in terms of time. The task is to find the peaks in the original signal starting from the filtered ones. The professor asked specifically to find them in a 40 range values range. Where should i specify this?
If you have the peak values and peak locations, filter the peaks using ‘logical indexing’ —
s = rand(40,1);
[pks,locs] = findpeaks(s)
pks = 12×1
0.8990 0.9961 0.9980 0.9159 0.5342 0.7040 0.7958 0.8126 0.6548 0.8179
locs = 12×1
4 8 10 13 15 21 23 25 27 29
peakmin = 0.5;
peakmax = 0.7;
Lv = (pks>=peakmin) & (pks<=peakmax); % Logical Vector
selected_pks = pks(Lv)
selected_pks = 2×1
0.5342 0.6548
selected_locs = locs(Lv)
selected_locs = 2×1
15 27
Beyond that, I have no idea what you want to do.
.
Matteo Svaldi
Matteo Svaldi le 17 Fév 2023
Thank you now it's clear, i misunderstood the task
Star Strider
Star Strider le 17 Fév 2023
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by