Hi Birsen,
From what I understand, your doubt is about fitting a curve to a set of experimental data using a custom equation. The equation includes a multiplication constant C, and initially, when C is set to 1E8, the curve fit does not match the experimental data. However, when the real data (y) is divided by C, a perfect fit is obtained.
It seems that the multiplication constant C in the fit equation is causing issues with the curve fitting. One possible reason for this discrepancy could be the scale of the data. The constant C = 1E8 might be too large for the data you are working with, causing numerical instability or overflow issues during the fitting process. Dividing the data by C effectively scales it down, making it more suitable for the fitting algorithm.
To address this issue, you can try rescaling your data before fitting the curve. Instead of using C = 1E8, you can divide the dependent variable y by a smaller constant or choose a scaling factor that is more appropriate for your data. For example:
C = 1E4; % Choose a smaller constant
y_scaled = y / C; % Rescale the dependent variable
% Fit the curve using the rescaled data
ft = fittype('(a + (b/(x^2)))*exp(-x/34)', 'dependent',{'y_scaled'}, 'independent',{'x_cm'}, 'coefficients', {'a','b'});
f = fit(x_cm, y_scaled, ft, 'StartPoint', [9.17E-11 0.75]);
% Retrieve the fitted coefficients
a_fit = f.a;
b_fit = f.b;
% Rescale the fitted coefficients back to the original scale
a = a_fit * C;
b = b_fit * C;
By rescaling the data and fitting the curve using the rescaled data, you can obtain the fitted coefficients (a_fit and b_fit) on the scaled-down version of the data. Then, you can rescale these coefficients back to the original scale by multiplying them with the scaling constant C.
Attached below are some documentation links that you may find helpful:
- Curve Fitting Toolbox Documentation (mathworks.com)
- Optimization Toolbox Documentation (mathworks.com)
Hope this helps!
Karan Singh Khat