Finding slope and y intercept

59 visualizaciones (últimos 30 días)
Rick
Rick el 20 de Oct. de 2014
Comentada: Venkata el 17 de Ag. de 2016
Hello, I was wondering if there is an easy way to find the slope and intercept of a line using MATLAB, like how it is so easy with Excel where you just plot the data and add a trendline, so then it will tell you the slope and intercept. Here is my code
tau = [15, 38, 100, 300, 1200];
CA = [1.5 1.25 1 0.75 0.5];
CA0 = 2;
dCdt = log((CA-CA0)./tau);
plot(log(CA),log((CA-CA0)./tau))
xlabel('ln(C_{A})')
ylabel('ln(C_{A}-C_{A0}/ \tau)')
I have a theory that says ln((CA-CA0)/tau) = ln(k) + alpha(ln(CA)), and I want to find alpha and ln k, which is my slope and intercept, respectively.
Thank you

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 20 de Oct. de 2014
Have you tried the Curve Fitting App (Curve Fitting Toolbox, req'd)
>>cftool
  3 comentarios
Andrew Reibold
Andrew Reibold el 20 de Oct. de 2014
If you just use polyfit to get linear data, just take two points from it and do the elementary calculations.
Sean de Wolski
Sean de Wolski el 20 de Oct. de 2014
Student Version usually does come with CFT. Try calling:
>>cftool
To see if you do.
Then you can fit arbitrary functions and you don't have to worry about linearizing them to play with polyfit.

Iniciar sesión para comentar.

Más respuestas (2)

Torsten
Torsten el 17 de Ag. de 2016
Did you look at the x-value where your "intercept" is between 0.32 and 0.33 ?
Best wishes
Torsten.
  3 comentarios
Torsten
Torsten el 17 de Ag. de 2016
The p2-value always refers to x=0.
Thus to get the computed value of 0.3046, you must look at the intercept at x=0, not at x=3.85.
Best wishes
Torsten.
Venkata
Venkata el 17 de Ag. de 2016
Now it makes sense.
Thanks a ton, Torsten.

Iniciar sesión para comentar.


Venkata
Venkata el 17 de Ag. de 2016
Editada: Venkata el 17 de Ag. de 2016
I've used 'cftool' for my data. The intercept is in between 0.32 and 0.33 as can be seen from the figure.
However, the 'p2' value is 0.3046, with 95% confidence bounds.
Please explain me this.

Categorías

Más información sobre Get Started with Curve Fitting Toolbox 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