Remove steps of adjacent points
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/734679/image.png)
0 Commenti
Risposta accettata
Matt J
il 10 Set 2021
Modificato: Matt J
il 10 Set 2021
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')
Più risposte (1)
Image Analyst
il 10 Set 2021
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 Commento
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!