![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/556427/image.png)
How to find a curve of best fit
2 ビュー (過去 30 日間)
古いコメントを表示
I have the following set of data.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/556282/image.png)
And from the looks of it it follows something along the lines of a log normal distrabution. But im having trouble fitting a log norm fit to it. How can I fit it? I have attached the data file for referance as well.
Update: I have come to realize that the data is not normalized so you cannot fit a proper log-norm curve to it. So i would first need to find the area under the data.
0 件のコメント
回答 (2 件)
Star Strider
2021 年 3 月 20 日
Using a completely different approach (System Identification Toolbox):
D = readmatrix('RLC1.xls');
t = D(:,1);
s = D(:,2);
Ts = mean(diff(t));
Tsd = std(diff(t));
Fs = 0.25;
[sr,tr] = resample(s,t,Fs);
Fn = Fs/2;
figure
plot(tr, sr)
grid
L = numel(tr);
FTs = fft(s)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, imag(FTs(Iv)))
grid
ylim([-1 1]*0.0005)
u = [1; zeros(L-1,1)];
tdd = iddata(sr, u, 1/Fs);
sys = tfest(tdd,3,2)
figure
compare(tdd,sys)
producing this transfer function data:
sys =
From input "u1" to output "y1":
0.007132 s^2 + 0.0004604 s + 1.881e-06
-------------------------------------------
s^3 + 0.01617 s^2 + 9.041e-05 s + 7.589e-08
Continuous-time identified transfer function.
Parameterization:
Number of poles: 3 Number of zeros: 2
Number of free coefficients: 6
Use "tfdata", "getpvec", "getcov" for parameters and their uncertainties.
Status:
Estimated using TFEST on time domain data "tdd".
Fit to estimation data: 95.47%
FPE: 4.55e-06, MSE: 4.304e-06
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/556427/image.png)
.
4 件のコメント
Star Strider
2021 年 3 月 20 日
If you want to fit it using the ‘lnf’ function, you would likely need to add a third ‘scaling’ parameter so that it would fit the curve:
lnf = @(p,x) p(3).*exp(-(log(x)-p(1)).^2./(2*p(2).^2)) ./ (x.*p(2)*sqrt(2*pi));
P = fminsearch(@(p)norm(s-min(s) - lnf(p,t)), rand(3,1));
A parameter set of about [5, 0.5, 75] produces a reasonable fit, so use those instead of the rand call as the initial parameter estimates.
Walter Roberson
2021 年 3 月 20 日
Ratio of two polynomials of degree 2 fits quite well, with approximate coefficients
P = [0.00213762295171613 56.4867705538076 455.003715200478]
Q = [1 -51.094359290793 32989.9993982203]
yfit = polyval(P, x) ./ polyval(Q,x);
This was using cftool, 'rat22' fit.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Linear Model Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!