Finding slope and y intercept
90 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
採用された回答
Sean de Wolski
2014 年 10 月 20 日
Have you tried the Curve Fitting App (Curve Fitting Toolbox, req'd)
>>cftool
3 件のコメント
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.
Sean de Wolski
2014 年 10 月 20 日
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
2016 年 8 月 17 日
Did you look at the x-value where your "intercept" is between 0.32 and 0.33 ?
Best wishes
Torsten.
3 件のコメント
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.
参考
カテゴリ
Help Center および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!