Remove steps of adjacent points

조회 수: 7 (최근 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 CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by