How to set x > 0, at 2nd order polynomial using polyfit.

1 回表示 (過去 30 日間)
Nurul Hazira
Nurul Hazira 2021 年 5 月 6 日
コメント済み: Nurul Hazira 2021 年 5 月 6 日
Hi I need help, I have imported a txt file into my matlab and have set the x and y value, then I got stuck to create the line on graph at x > 0. Below is my normal code without set x > 0.
p2 = polyfit(x,y,2);
f = polyval(p2,x);
plot(x,f,'-')

採用された回答

KSSV
KSSV 2021 年 5 月 6 日
idx = x > 0 ;
x = x(idx);
y = y(idx) ;
p2 = polyfit(x,y,2);
f = polyval(p2,x);
plot(x,f,'-')
  1 件のコメント
Nurul Hazira
Nurul Hazira 2021 年 5 月 6 日
it is working now! thank you so much :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by