Fitting a simple digital signal from noisy measurements (piecewise linear fitting?)

1 次查看(过去 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?

回答(1 个)

Star Strider
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 个评论
Daniel H
Daniel H 2021-10-8
Thank you, that’s a great start.
But my question was also about the fitting itself,m from the measurement data. For example, such that the quadratic error between the measurements and your function is minimized
Star Strider
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 CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by