Curve to fit a loglog graph and its equation

2 visualizaciones (últimos 30 días)
Khishendran Mahendran
Khishendran Mahendran el 23 de Ag. de 2020
Comentada: Uygur Kinay el 7 de Abr. de 2022
i have write a code for my given set of data and could not figure how to get a curve line to fit it with an equation
this is the code i have writen with the data points
y=[0.02521 0.47575 0.035403 0.03479 0.025683 0.025397 0.021046];
x=[0 0.5 1 1.5 2 2.5 3];
y=y./1000;
loglog(x.',y.','o')
hold on
f=polyfit(log(x),log(y),1);
fity=polyval(f,log(x));
loglog(x,exp(fity))
  2 comentarios
Sam Chak
Sam Chak el 23 de Ag. de 2020
There are only 7 points, so probably insufficient to produce a good fitting. Try to obtain more data points.
This is just one of many possible equations to fit the 7 points:
Goodness of fit:
  • SSE: 0.0001094
  • R-square: 0.9994
  • Adjusted R-square: 0.9992
  • RMSE: 0.004677
Uygur Kinay
Uygur Kinay el 7 de Abr. de 2022
I have 30 data for the equation and I got two equations in excel one is polynominal and other is logoritmic equation.
How we can do it on matlab,Could you guide me?

Iniciar sesión para comentar.

Respuestas (1)

Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato el 23 de Ag. de 2020
There are some issues with your fit. First, log(0) is not defined, so what you expect to become from a fit that uses log(0)? If you really want to use this point to a logarithmic fit you have to make some consideration like calculating log(x+eps) instead of log(x), although this will unlikely lead to a reasonable model. Second, what type of function you think you have? The second y value has a way higher value than all others, it is an outlier/measurement error that needs to be removed? Or you are modelling a probability function and there is the peak? If so, why use a 1 degree exponential function and not a probability function such as a gaussian to model it?
If you don't define what type of model you're expecting to have it doesn't make much sense to make a fit on it.

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by