How to cut a signal en two parts?

조회 수: 2 (최근 30일)
IVÁN BASTIÁN CHIMAL
IVÁN BASTIÁN CHIMAL 2016년 4월 20일
댓글: IVÁN BASTIÁN CHIMAL 2016년 4월 20일
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.

답변 (1개)

Baltam
Baltam 2016년 4월 20일
편집: Baltam 2016년 4월 20일
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
IVÁN BASTIÁN CHIMAL
IVÁN BASTIÁN CHIMAL 2016년 4월 20일
Thank you so much, that's what I need. Cheers my friend

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by