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

 채택된 답변

Sean de Wolski
Sean de Wolski 2014년 10월 20일

0 개 추천

Have you tried the Curve Fitting App (Curve Fitting Toolbox, req'd)
>>cftool

댓글 수: 3

Rick
Rick 2014년 10월 20일
The curve fitting toolbox is something that you have to pay extra for, right? By the way, I guess just using polyfit will do the trick.
I have the students edition, and I dont know if it comes with the curve fitting toolbox. If it does I really want to know how to access it!!
Andrew Reibold
Andrew Reibold 2014년 10월 20일
If you just use polyfit to get linear data, just take two points from it and do the elementary calculations.
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.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Torsten
Torsten 2016년 8월 17일

1 개 추천

Did you look at the x-value where your "intercept" is between 0.32 and 0.33 ?
Best wishes
Torsten.

댓글 수: 3

Venkata
Venkata 2016년 8월 17일
x-intercept: 3.85; y-intercept: 0.328
Is this what you are asking?
Torsten
Torsten 2016년 8월 17일
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 2016년 8월 17일
Now it makes sense.
Thanks a ton, Torsten.

댓글을 달려면 로그인하십시오.

Venkata
Venkata 2016년 8월 17일
편집: Venkata 2016년 8월 17일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

태그

질문:

2014년 10월 20일

댓글:

2016년 8월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by