How to fix jump signal?

17 ビュー (過去 30 日間)
Tyann Hardyn
Tyann Hardyn 2022 年 4 月 12 日
コメント済み: Star Strider 2022 年 4 月 13 日
Hi, Community
I have a problem to handle jump noise like this :
My question is simple... How to make the jumped harmonic signals to become linear again according to previous signals? for example like this signal below :
Is kinda difficult to fix it without a manual remove.. Thank you so much, everyone....

採用された回答

Star Strider
Star Strider 2022 年 4 月 13 日
One approach —
Fs = 256;
t = linspace(0, Fs*10-1, Fs)/Fs;
s1 = randn(size(t))*0.5; % Create Original Signal
ov = 10*(t>2 & t < 5) + 5*(t>=5 & t < 7) + 10*(t>=7);
s2 = s1 + ov; % Create Signal With Step Discontinuities
figure
plot(t, s2)
grid
TF = ischange(s2, 'mean', 'Threshold',5); % Find Abrupt Changes
iscidx = find(TF); % Numeric Indices
iscidxa = [1 iscidx numel(t)]; % Augment 'iscidx'
s2r = zeros(size(t)); % Recovered Original Signal
for k = 1:numel(iscidxa)-1
idxrng = iscidxa(k) : iscidxa(k+1);
s2r(idxrng) = s2(idxrng) - mean(s2(idxrng)); % Detrend Step discontinuities
end
% s2r = filloutliers(s2r,'linear'); % Remove Any Remaining 'Spikes' (If Necessary)
figure
plot(t, s2r)
hold on
plot(t, s1, '--')
hold off
grid
legend('Detrended Signal','Original Signal', 'Location','best')
See the documentation for ischange for details on it.
It will be necessary for you to test it with your signal.
.
  2 件のコメント
Tyann Hardyn
Tyann Hardyn 2022 年 4 月 13 日
編集済み: Tyann Hardyn 2022 年 4 月 13 日
I actually already found the ischange function, but when i put my data into the varargin, it show error. After that, i realize that my data contain with NaN, so i use isnan and it already worked. And i try also with this function :
[ipoint,~] = findchangepts(input,...
'MaxNumChanges',maxnum);
Anyways, Thats great Sir, i ll try your approach, thank you so much, Sir....
Star Strider
Star Strider 2022 年 4 月 13 日
As always, my pleasure!
The NaN values are considered by MATLAB to be ‘missing’, so remove them with rmmissing (that removes all the values that correspond to any missing value) or fillmissing to interpolate the missing values.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 4 月 13 日
Perhaps do a movmean() and subtract that from the signal ?
Though possibly you might not be happy with the results at the jump boundaries.

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by