Fitting the curve problem
조회 수: 3 (최근 30일)
이전 댓글 표시
I try to fit an s-shape curve with the function that I define. Actually I get a not-so-bad fitting by setting a more appropriate boundary and starting point. One remaining question is that although the fit is better, the parameters' range is still big. Anyone has any advice for this? Attached file is the data file for Ch4.
Final_time=10;
recordLength=size(Ch4);
recordLength=recordLength(1);
Time=[linspace(0,Final_time*1000,recordLength)]';
Ch4_mV=Ch4.*1000;
[pks,locs]=findpeaks(Ch4_mV,'MinPeakProminence',30);
for j=3
duration_fit=Time(locs(j)-6:locs(j)+10);
y_duration_fit=Ch4_mV(locs(j)-6:locs(j)+10);
FitFunction=@(a,b,A,B,F,e,x)F.*(b.*A-(x-a).*B)./((x-a).^2+b^2)+e;
options=fitoptions('Method','NonlinearLeastSquares','Upper',[Time(locs(j)+50) Time(8)-Time(1) 1 1 pks(j)+10 0],'Lower',[Time(locs(j)-50) 0 -1 -1 pks(j)-10 -15],'StartPoint',[Time(locs(j)),1,1,Time(locs(j)+5)-Time(locs(j)-2),pks(j),1]);
[fitcurve,gof]=fit(duration_fit,y_duration_fit,FitFunction,options)
plot(fitcurve,duration_fit,y_duration_fit);
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/921169/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/921174/image.png)
댓글 수: 4
Sam Chak
2022년 3월 10일
Looks like the Stribeck friction model. No harm trying to fit with the suggested model, but you need to shift the center to approximately
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/921264/image.png)
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!