How to cut a signal en two parts?

2 ビュー (過去 30 日間)
IVÁN BASTIÁN CHIMAL
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 Center および File ExchangePerformance and Memory についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by