Azzera filtri
Azzera filtri

How to cut a signal en two parts?

1 visualizzazione (ultimi 30 giorni)
IVÁN BASTIÁN CHIMAL
IVÁN BASTIÁN CHIMAL il 20 Apr 2016
Hi friends, I'm new usign matlab,I would like to know, how to cut a signal en two parts? I mean, divide the low and the high part . I add a simple code and an image as a example.
ylim([0 6])
x=[0 0 5 5 5 0 0];
plot(x,'r')
[maximo,MaxFreq]=findpeaks(x,'NPeaks',1) %%here we found the max peak, in this case is 5
media= maximo-(maximo/2) %%here we calculate the half signal and the result is 2.5
plot(x)
hold on
plot(0:length(x),media,'*')
Thank you very much and sorry for my english.

Risposte (1)

Baltam
Baltam il 20 Apr 2016
Modificato: Baltam il 20 Apr 2016
You better make some x-axis parameter, I called it 't'. From there on it is basically the same as wat Star strider told you.
x=[0 0 5 5 5 0 0];
t = 1:length(x); % Make x-axis value to plot
[maximo,MaxFreq]=findpeaks(x,'NPeaks',1); %%here we found the max peak, in this case is 5
media= maximo-(maximo/2); %%here we calculate the half signal and the result is 2.5
plot(t,x,[t(1),t(end)],[media,media])
% Make more points on the curve by using interpolation
T = linspace(0,length(x),1000);
X = interp1(1:length(x),x,T);
% Filter data dependent on media. Devide in top and bottom.
T_top = T(X>media);
T_bottom = T(X<media);
X_top = X(X>media);
X_bottom = X(X<media);
% Plot again
figure(2),
plot(T_top,X_top,T_bottom,X_bottom)
Kind regards
Baltam
  1 Commento
IVÁN BASTIÁN CHIMAL
IVÁN BASTIÁN CHIMAL il 20 Apr 2016
Thank you so much, that's what I need. Cheers my friend

Accedi per commentare.

Categorie

Scopri di più su Time-Frequency Analysis in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by