How to "force" a data to start and end at zero y values?
13 views (last 30 days)
Show older comments
Vitor Sotero
on 7 Sep 2020
Commented: Vitor Sotero
on 23 Sep 2020
Hi!
How can I can force the end point to zero?
Red: original data (after cumtrapz);
Blue: filtered data (hp);
But I know that the data has to end at zero y value. Is there any way that I can "rotate" the blue line to fit? I looked at fit and polyfit, but I might doing something wrong.
0 Comments
Accepted Answer
Image Analyst
on 7 Sep 2020
Just use polyfit on the first and last points to get a ramp. Then subtract the ramp from all the y values. The first and last point will subtract to give 0 and all the other points in between will be proportionally lowered.
coefficients = polyfit([x(1), x(end)], [y(1), y(end)], 1)
ramp = polyval(coefficients, x);
yFit = y - ramp;
11 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!