Fit experimental results to an equation and get fit parameters

5 visualizaciones (últimos 30 días)
Ahmed Razeen
Ahmed Razeen el 25 de Ag. de 2020
Respondida: Ayush Gupta el 2 de Sept. de 2020
Hi,
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...
;1.27384;1.34877;1.4237;1.49864;1.57357;1.6485;1.72343;1.79836;1.8733;1.94823;2.02316];
% y-axis
Re_Before = [397317000;313600000;245333000;189330000;145070000;112878000;92863500;84352900;85755700....
;94968300;110273000;131418000;160374000;201494000;261214000;347602000;469832000;637160000;856592000;1128290000;1438380000;1751530000];
% 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)
effective_mass
C
times = linspace(Freq(1),Freq(end));
plot(Freq,Re_Before,'ko',times,fun(p,times),'b-')
legend('Data','Fitted exponential')
title('Data and Fitted Curve')
ylabel('Real Conductivity (S/m)')
xlabel('Frequency (THz)')
grid on
  1 comentario
Matt J
Matt J el 25 de Ag. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Ayush Gupta
Ayush Gupta el 2 de Sept. de 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:
fit(Freq,Re_Before,'smoothingspline')
plot(ans,Freq,Re_Before)
For examples on how to use fit function and its documentation click here.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by