How do I differentiate between wave patterns in multiple signals?

I have a dataset that contains 6 signals and I want to identify the outlier pattern. On normal operation I see pattern 1 convert to pattern 2. On some cases I am seeing a third pattern that occurs on the transition from 1 to 2.
Is there a way to successfully identify this and tell which signal it was found on?

Respuestas (2)

Umar
Umar el 27 de Jun. de 2026 a las 7:59
Editada: Umar el 27 de Jun. de 2026 a las 8:03
Hi @Sridutt, Great question! I ran into the same problem and worked out a solution that does exactly what you need — detecting the outlier Pattern 3 and telling you which signal channel it appeared on. Here is the approach and what each step does: PRE-PROCESS — Run medfilt1 on each channel to remove noise spikes without blurring the square-wave edges. FIND EDGES — Use findchangepts with the 'rms' statistic to locate every rising and falling edge across all 6 signals. PULSE METRICS — Run pulsewidth and risetime on each channel. In normal operation these numbers are nearly identical across all channels, so any channel showing a significantly different value is worth investigating. RISING-EDGE DTW (the key step) — Instead of comparing full plateau segments (which causes false positives on every channel), cut a narrow ±80 ms window centred on each rising edge and compare it to a clean reference template using Dynamic Time Warping (dtw). Normal transitions score low DTW distance. A transition that goes through an anomalous Pattern 3 shape scores much higher. The threshold is set adaptively as mean + 1.5 standard deviations across all windows, so it calibrates itself to your signal amplitude automatically. ischange SWEEP — Use ischange with a mean statistic as a quick cross-check. Anomalous channels will show a noticeably higher flag count than the others. Results on a synthetic 6-channel dataset with one injected Pattern 3 anomaly: DTW threshold: 27.25 ANOMALY detected → VM4, sample 2001, t = 2.000s, DTW = 61.36 All other channels: completely clean, no false positives The ischange sweep independently confirmed VM4 with 16 flags versus 9 for every other channel. To use this with your real data, just replace the synthetic data section at the top with: data = load('your_data_file.mat'); signals = data.signals; % N x 6 matrix t = data.t; % N x 1 time vector in seconds Fs = 1 / (t(2) - t(1)); The threshold and window size are both auto-scaled to your sampling rate and signal amplitude, so it should work without manual tuning. The final report prints the channel name, sample index, and timestamp for every Pattern 3 occurrence it finds. Please review attached. Hope this helps!
Image Analyst
Image Analyst hace alrededor de 2 horas
Editada: Image Analyst hace alrededor de 2 horas
Not sure by exactly what you mean by " identify this and tell which signal it was found on". Do you mean how to tell if pattern 2 occurred on VM1, VM2, VM3, etc.? OR do you mean for a given signal, which of the tall flat topped pulses the pattern happened after, like the 2nd pulse or the 4th one?
It looks like VM3 also hase the same pattern 3 as signal VM5. Is that true?
How do you plan on handling edge effect? for example the final small hump in VM4 looks like a cropped version of the pattern 2, or it could be a pattern 3.
How consistent are the amplitudes? It looks like the max is always at 7 but with some signals there is a noisy baseline while others don't have that.
Does pattern 3 always have a peak amplitude of less than 3? If so, threshold at about 0.2 to identify patterns, then use regionprops to find the max value of the pattern. If it's more than 3, it's not a pattern 3 but if it is, it is a pattern 3. For example
inPattern = signal > 0.2; % Find all regions more than 0.2.
props = regionprops(inPattern, 'MaxIntensity');
allMaxIntensities = [props.MaxIntensity]; % Extract from structure into vector.
itsPattern3 = find(allMaxIntensities < 3);
if ~isempty(itsPattern3)
% Find out which of the pattern is pattern 3.
fprintf('Pattern 3 is pattern #%d.\n', itsPattern3); % Print out which pulse is pattern 3.
end
The above code requires the Image Processing Toolbox.
You can determine the noise threshold with histogram. You should have peaks at 7 and 0 or 0.1 or so.
Upload your signals in a .mat or text file if you want anyone to try anything.

Productos

Versión

R2025a

Preguntada:

el 27 de Jun. de 2026 a las 2:33

Editada:

el 27 de Jun. de 2026 a las 16:18

Community Treasure Hunt

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

Start Hunting!

Translated by