How to fit an integral with more than one variables?

4 次查看(过去 30 天)
Hello,
I'm trying to fit data with an integral with 4 variables and I'm not sure how to write the fit.
I have two matrix I(y-axis) and tau(x-axis), and here is the part of my script which fails:
syms d mu sig x
s = fitoptions('Method','NonlinearLeastSquares','Lower',[0.05 0.05],'Upper',[100 100],'Startpoint',[0.05 0.05]);
fff=@(mu,sig,x)vpaintegral((1./(d.*sig.*sqrt(6.28))).*exp((-(log(d)-mu).^2)./(2.*sig.^2)).*0.5.*(1-exp(-(d.*x).^1.1)).*cos(1.9.*d.*x),d,0.05,10)
fitint= fittype(fff, 'options',s)
f3=fittype(tau,Indq,fitint) %ligne 45
I get the following errors:
Error using fittype>iCreateFittype
First input argument must be a string scalar or character vector, cell array or anonymous function.
Error in fittype (line 330)
obj = iCreateFittype( obj, varargin{:} );
Error in Analyse_DQ (line 45)
f3=fittype(tau,I,fitint)
Any suggestions?
Thanks

采纳的回答

Pooja Kumari
Pooja Kumari 2024-10-10
Hi LR,
I understand that you are facing "Error using fittype>iCreateFittype" error when you're trying to fit your data using a custom function that involves an integral.
The error you're encountering is due to incorrect usage of the "fittype" function.
f3=fittype(tau,Indq,fitint) %line 45
Perform the fitting instead of "fittype" function
[fittedCurve, gof] = fit(tau, I, fitint);
"First input argument must be a string scalar or character vector, cell array or anonymous function." is occuring due to matrix tau(x-axis).
You can refer to the below documentation for more information on "fittype" function:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by