How to match the rising starting point of the graph

1 view (last 30 days)
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.
  4 Comments
dpb
dpb on 21 May 2022
Alternately, one might consider a piecewise regression of the section from beginning to the peak. I've posted this several times, the one I found first is at <Piecewise Regression>
대수 김
대수 김 on 22 May 2022
Thank you for the good advice.
I'll look it up and study it.

Sign in to comment.

Accepted Answer

Star Strider
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 —
LD = load('ld.mat');
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 —
.
  4 Comments
대수 김
대수 김 on 22 May 2022
Edited: 대수 김 on 22 May 2022
I'm late to thank you because I was studying while modifying the code you told me by myself.
Thanks to you, I get to know new functions and code structures.
Especially zci(k) = find(diff(sign(yf(:,k)-Threshold)),1,"first"); was very helpful.
Is there a reason why you usually use sgolayfilt among data filtering?
Have a nice day!
Star Strider
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.
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!