How to match the rising starting point of the graph

4 views (last 30 days)
대수 김 on 21 May 2022
Commented: Star Strider on 22 May 2022
I want the graphs to have the same rising starting point.
Moving the graph by a certain value has a similar starting point.
However, it is very difficult and takes a long time to find the values one by one.
There is so much noise in the signal that I don't know how to code it.
I subtracted y(:,1) from the code to start from the origin.
대수 김 on 22 May 2022
Thank you for the good advice.
I'll look it up and study it.

Star Strider on 21 May 2022
This is my best effort. I could not get the other functions I tried (ischange, findchangepts, islocalmin, etc.) to work, so I went with a somewhat less-sophisticated approach that finds the approximate indices of the threshold, then uses those values to correct for the x-offsets —
x = LD.signal.x;
y = LD.signal.y;
L = numel(x);
yf = sgolayfilt(y, 3, 1501); % Filter Signal
Threshold = 0.000075;
for k = 1:size(y,2)
zci(k) = find(diff(sign(yf(:,k)-Threshold)),1,"first") % Index Of First Threshold-Crossing
end
Lmax = L-max(zci)-1000; % Maximum Vector Length
Offset = 2500; % Set To 0 To Begin At Origin
for k = 1:size(y,2)
idxrng = (zci(k) : zci(k)+Lmax)-Offset; % Index Range With Initial Offset
yfc(:,k) = yf(idxrng,k); % Filtered, Corrected
yc(:,k) = y(idxrng,k); % Original, Corrected
end
figure
plot(x(1:Lmax+1),yfc)
grid
title('Filtered, Shift-Corrected')
legend(compose('y_%d',1:size(y,2)), 'Location','best')
figure
plot(x, yf)
grid
title('Filtered, Uncorrected')
legend(compose('y_%d',1:size(y,2)), 'Location','best')
figure
plot(x(1:Lmax+1), yc)
grid
title('Original, Shift-Corrected')
legend(compose('y_%d',1:size(y,2)), 'Location','best')
The code produces three plots, the third being the most relevant —
.
Star Strider on 22 May 2022
My pleasure!
I use sgoiayfilt to filter the data in order to remove most of the noise. Without the filtering, with the noise left in, the problem is essentially impossible to solve.
.