Remove steps of adjacent points

2 ビュー (過去 30 日間)
Konvictus177
Konvictus177 2021 年 9 月 10 日
編集済み: Matt J 2021 年 9 月 10 日
Hi,
I have a signal which shows repeating lower peaks due to end point and new starting point being on a different level. What is the fastest and easiest way to remove the step/peak and lift all points to the right in such a way that the two connecting points are on the same level and the rest of the signal is lifted with the same amount.
Thanks.

採用された回答

Matt J
Matt J 2021 年 9 月 10 日
編集済み: Matt J 2021 年 9 月 10 日
Perhaps as follows:
threshold=0.5;
t=0:0.01:3;
signal=log(mod(t,1)+1);
D=diff(signal(:).');
D(abs(D)>threshold)=0;
signal2=cumsum([signal(1),D]);
plot(t,signal, '-x',t,signal2); legend('Original','Modified')
  1 件のコメント
Matt J
Matt J 2021 年 9 月 10 日
編集済み: Matt J 2021 年 9 月 10 日
If the jumps are occuring at known intervals N, you could also do,
D=diff(signal(:).');
D(N:N:end)=0;
signal2=cumsum([signal(1),D]);

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2021 年 9 月 10 日
You said you have "lower peaks due to end point". So it's always the last point that drops. So the last point is bogus and should basically be ignored? Are you obtaining a sequence of signals, And then you just stitch on the next signal onto the master, growing signal? So you could do
allSignals = [];
for k = 1 : numberOfSignalsToStitch
thisSignal = HoweverYouGetIt();
% Crop off/ignore last element.
thisSignal(end) = [];
if k == 1
allSignals = thisSignal;
else
% Put first point where last point is
thisSignal = thisSignal - thisSignal(1) + allSignals(end);
% This will "lift" the current signal to the end of the last signal.
allSignals = [allSignals, thisSignal]
end
end
If you need more help, attach your signal(s) in a .mat file.
  1 件のコメント
Konvictus177
Konvictus177 2021 年 9 月 10 日
編集済み: Konvictus177 2021 年 9 月 10 日
It is the new starting point that is on a lower level than the last point. So the new starting point would we bogus. This new starting point should not be removed but be on the same level as the last point like a straight line connection. All points after the first point should be lifted with the same amount the first point is lifted to make the straight connection.

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

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by