How to cut a signal en two parts?
조회 수: 2 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Performance and Memory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!