MATLAB: How to fit an integral with data points in Matlab, where the integration limit can vary

curve fittingintegrationMATLAB

How to fit an integral with data points in Matlab, where the integration limit can vary
By varying the integration limit how do I fit some data points in Matlab?

Best Answer

If I want to add an extra term in the above expression (like -AT^3, where A constant) so the code would be like this or different. can u confirm me?
Tv = linspace(200, 300, 10).'; % vector of T values
Pv = Tv.^2; % vector of P values
P_mdl = @(P0, R, C, A, TT) arrayfun(@(T) P0 - A.*T.^3 + 4*R.*C.*(T/C).^5 * integral(@(x) x.^5./(exp(x)-1).*(1-exp(-x)), 0, (C/T)), TT);
sol = lsqcurvefit(@(param, T) P_mdl(param(1), param(2), param(3), param(4), T), rand(4,1), Tv, Pv);
P0_sol = sol(1);
R_sol = sol(2);
C_sol = sol(3);
A_sol = sol(4);