Fitting a simple digital signal from noisy measurements (piecewise linear fitting?)
2 次查看(过去 30 天)
显示 更早的评论
I have a digital signal from scope measurements:
Note that the transitions seem to be mainly due to slewing (=charging load capacitance with a constant current) as opposed to bandwidth limitation (linear system, RC, ...).
This suggests this signal can be well described by a piecewise linear function.
What is the easiest way to do this in MATLAB?
0 个评论
回答(1 个)
Star Strider
2021-10-8
I cannot find a built-in function that incorporates a slew rate, so so programming it yourself would be necessary.
One option could be:
sqs = @(t) (10*t).*(t>=0 & t<0.1) + 1.*(t>=0.1 & t<0.2) + (3-10*t).*(t>=0.2 & t <0.3);
t = linspace(0, 1);
figure
hold on
for n = 0:0.5:2;
plot(t+n, sqs(t), '-b')
end
hold off
grid
Adjust the slew rate, signal segment durations, and amplitudes to get the desired result.
I leave the rest to you.
.
2 个评论
Star Strider
2021-10-8
My pleasure!
The function I provided should be a prototype for that (set certain constants to instead be parameters, and use that as the objective function), unless a model of the circuit that produced that plot is available, and if so, just fit those parameters. The fitting process would be the same. The Optimization, Global Optimization, and Statistics and Machine Learning Toolboxes have nonlinear parameter estimation routines that should works with that, although the Global Optimization Toolbox functions could be more robust.
Another option would be to use the System Identification Toolbox functions to fit it. (Remember to use the compare function to get a visual representation of how good the fit is.)
.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!