Fit experimental results to an equation and get fit parameters

21 views (last 30 days)
I have the following code, which I try to fit some results to an equation and evaluate the parameters, but the fit didn't match at all. I tried also to change p0 values, but no fit occurs.
any help?
% x-axis
Freq = [0.44959;0.52452;0.59945;0.67439;0.74932;0.82425;0.89918;0.97411;1.04905;1.12398;1.19891...
% y-axis
Re_Before = [397317000;313600000;245333000;189330000;145070000;112878000;92863500;84352900;85755700....
% Pre_Defined
elect = 1.6e-19;
e_mass = 9.11e-31;
effective_mass = 3.8*e_mass;
epsilon = 8.85e-12;
C = -1;
%% Fitting:
fun = @(p,Freq) real(((epsilon*p(1)^2)./(p(2)-1i.*Freq)).*(1+((C*p(2))./(p(2)-1i.*Freq))));
p0 = [1e27,1e7];
p = lsqcurvefit(fun,p0,Freq,Re_Before);
%% calculate Density and output needed values
Plasma_Freq_Squared = p(:,1);
Electron_Density = epsilon*Plasma_Freq_Squared*effective_mass/elect^2
Gamma = p(:,2)
times = linspace(Freq(1),Freq(end));
legend('Data','Fitted exponential')
title('Data and Fitted Curve')
ylabel('Real Conductivity (S/m)')
xlabel('Frequency (THz)')
grid on
  1 Comment
Matt J
Matt J on 25 Aug 2020
We can't help much because we have no way to be sure that you are using an appropriate model equation. At the very least, however, I think you should change units on the y-axis so the order of magnitude is not 1e18.

Sign in to comment.

Answers (1)

Ayush Gupta
Ayush Gupta on 2 Sep 2020
The fit function in MATLAB can be used to fit a data and the type of fitting can be specified by fittype argument in the function. Refer to the following code for fitting the data and plotting in on the map:
For examples on how to use fit function and its documentation click here.




Community Treasure Hunt

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

Start Hunting!