Is there any way to do LFIT (general linear least-squares fit ) on the time series data using MATLAB?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How to do the attched linear least-square fitting equation on time series data in matlab?
y = a + b*t + c*t^2 + d*sin(2*pi*t) + e*cos(2*pi*t) + f*sin(2*pi*t*2) + g*cos(2*pi*t*2)
a,b,c ... are parameters. t is time and y is dependent variable.
0 Kommentare
Antworten (1)
Star Strider
am 27 Jul. 2021
That depends entirely on what you want to do.
One approach:
syms a b c d e f g t
y = a + b*t + c*t^2 + d*sin(2*pi*t) + e*cos(2*pi*t) + f*sin(2*pi*t*2) + g*cos(2*pi*t*2);
yfcn = matlabFunction(y, 'Vars',{[a b c d e f g],t})
This will work in the Optimization Toolbox and Statictics and Machine Learning Toolbox nonlinear parameter estimation funcitons. Specify the initial parameter estimates as a row vector.
tv = linspace(0, 10, 50); % Create Data
yv = exp(-(tv-5).^2) + randn(size(tv))/10; % Create Data
B0 = rand(1,7); % Choose Appropriate Initial Parameter Estimates
B = nlinfit(tv(:), yv(:), yfcn, B0)
The Curve Fitting Toolbox does it differently:
yfit = fittype('a + b*t + c*t^2 + d*sin(2*pi*t) + e*cos(2*pi*t) + f*sin(2*pi*t*2) + g*cos(2*pi*t*2)', 'independent',{'t'});
yfit = fit(tv(:) ,yv(:), yfit,'start',B0)
Experiment to get the result you want.
.
6 Kommentare
Star Strider
am 28 Jul. 2021
I still do not understand what you want to do.
If you want to filter the data, use the lowpass (or bandpass, to eliminate the baseline offset and drift) functions. I have no idea what you want to do, however
[yr_filt,lpdf] = lowpass(yr, 4E-3, Fs, 'ImpulseResponse','iir');
will work for the lowpass filter, and
[yr_filt,bpdf] = bandpass(yr,[1E-5, 4E-3], Fs, 'ImpulseResponse','iir');
for the bandpass design (although it might be necessary to experiment with the lower passband edge).
.
Siehe auch
Kategorien
Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!