フィルターのクリア

How to find the slope of regression between two sets of data and save the scatter plot as fig

9 ビュー (過去 30 日間)
Hana
Hana 2014 年 12 月 19 日
編集済み: Star Strider 2014 年 12 月 19 日
a=load(a) S=load(S) T=load(T)
aa= find(a>=0 & a <0.2); x1 = S(aa); y1 = TB(aa); scatter(x1,y1,'MarkerFaceColor','g','MarkerEdgeColor','g');
bb= find (a>=0.2 & a <0.4); x2 = S(bb); y2 = T(bb); figure; hold on; scatter(x2,y2,'MarkerFaceColor','b','MarkerEdgeColor','b');

回答 (1 件)

Star Strider
Star Strider 2014 年 12 月 19 日
Use the polyfit function. Since you mention ‘slope’, you would need to use a linear (first-degree polynomial).
Assuming you want to do a regression between ‘x2’ and ‘y2’, this will work:
p = polyfit(x2, y2, 1);
slope = p(1);
Here ‘p’ is the parameter vector.
  2 件のコメント
Hana
Hana 2014 年 12 月 19 日
Thanks for your reply.How can i save the scatterplot as fig?
Star Strider
Star Strider 2014 年 12 月 19 日
編集済み: Star Strider 2014 年 12 月 19 日
My pleasure.
Use the savefig function.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by