フィルターのクリア

help with regression fitting - curvilinear

3 ビュー (過去 30 日間)
Eric Escoto
Eric Escoto 2021 年 10 月 4 日
コメント済み: Eric Escoto 2021 年 10 月 4 日
I lost on why the model cant plot a single line after fitting a regression to the data (example data attached).
I'm using,
p = polyfit(data(:,2), data:,1), 2);
ypoly = poly val(p, data(:,2));
figure
plot(data(:,2), data(:,1), 'o')
hold on
plot(data(:,2), ypoly)
The figure looks like this (attached) with lines all over instead of one smooth curve.

採用された回答

KSSV
KSSV 2021 年 10 月 4 日
編集済み: KSSV 2021 年 10 月 4 日
load('data.mat')
p = polyfit(data(:,2), data(:,1), 2);
xi = linspace(min(data(:,1)),max(data(:,2)),1000) ;
yi = polyval(p, xi);
figure
plot(data(:,2), data(:,1), 'o')
hold on
plot(xi,yi)
You made some syntax errors in the given code. Check with the given code.
  1 件のコメント
Eric Escoto
Eric Escoto 2021 年 10 月 4 日
Thanks!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by