# Help with Cross-correlation and Auto-correlation

4 visualizzazioni (ultimi 30 giorni)
David Jones il 26 Giu 2021
Commentato: David Jones il 30 Giu 2021
Hi
I don’t have that much experience in MATLAB, I hope someone can point me in the right direction, I am looking at breathing and the rate and various ways to detect this. I am currently looking into Cross correlation and auto correlation can somebody please help me setup some basic code and give me a few pointers.
I have attached a file which has 6000 samples, 100 samples per second, over 60 seconds.
Any help would be greatly appreciated.
Kind Regards
David
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Image Analyst il 26 Giu 2021
Try this:
plot(y, 'b-', 'LineWidth', 2);
grid on;
% Find peaks
[peakValues, indexesOfPeaks] = findpeaks(y, 'MinPeakDistance', 200, 'Threshold', 1000);
% Plot them.
hold on;
plot(indexesOfPeaks, y(indexesOfPeaks), 'rv', 'LineWidth', 2, 'MarkerSize', 10);
% Find valleys
[valleyValues, indexesOfValley] = findpeaks(-y, 'MinPeakDistance', 200, 'Threshold', 1000);
valleyValues = -valleyValues;
% Plot them.
hold on;
plot(indexesOfValley, y(indexesOfValley), 'r^', 'LineWidth', 2, 'MarkerSize', 10);
##### 5 CommentiMostra 3 commenti meno recentiNascondi 3 commenti meno recenti
Image Analyst il 29 Giu 2021
Not sure what that means but you can create an x axis if you want with linspace. If the total length of y is 60 seconds, you can make x like
x = linspace(0, 60, length(y));
David Jones il 30 Giu 2021
Hi
I am strugling to get the display to show the 60s of data correctly, please see atached display I need to display the last graph (5) with the x axis showing the correct timimng , could you please help.
David

Accedi per commentare.

### Categorie

Scopri di più su Smoothing and Denoising in Help Center e File Exchange

R2020a

### Community Treasure Hunt

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

Start Hunting!

Translated by