polyfit equation in scatter in matlab

3 ビュー (過去 30 日間)
Leela Sai Krishna
Leela Sai Krishna 2019 年 5 月 20 日
回答済み: Star Strider 2019 年 5 月 20 日
i am trying to insert the polyfit equation
my code as follows
txt1 = ['y = ' num2str(p(1)) '*x + ' num2str( p(2)) ''];
text(p(1), p(2), txt1);
but it shows that equation along the polyfit line.
How to show it at top left corner or specified location.
Thanks in advance.

回答 (2 件)

Leela Sai Krishna
Leela Sai Krishna 2019 年 5 月 20 日
I got Answer
text.Position=[x_axis value,y_axis value];
it works.
I posted this for other users reference.
If any suggestions/ modifications please suggest me.
Thanks and regards.

Star Strider
Star Strider 2019 年 5 月 20 日
Try this:
text(min(xlim)+0.1*max(xlim), max(ylim)-0.1*max(ylim), sprintf('y = %.3f*x + %.3f', p)) % Top Left Corner
Experiment to get the result you want.

カテゴリ

Help Center および File ExchangeHistorical Contests についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by