フィルターのクリア

Fit data to array values

10 ビュー (過去 30 日間)
Divij Gupta
Divij Gupta 2021 年 7 月 27 日
回答済み: KSSV 2021 年 7 月 27 日
I have a certain array of theoretical values which forms the y values of a graph. This graph is not analytic, so the theoretical array values are numerically generated. I want to see how good this theoretical array is to an actual data array. For eg, I have a theoretical array [1 1 1 1 1] which represents 5 points on a linspace(1,5). The data array is [0.987,0.95,1.06,1.02,1.04] over the same linspace. I want to see how good of a fit it is (calculate an R-squared value for the fit).

回答 (1 件)

KSSV
KSSV 2021 年 7 月 27 日
x = 1:5 ;
y = [0.987,0.95,1.06,1.02,1.04] ;
p = polyfit(x,y,2) ;
yi = polyval(p,x) ;
figure
hold on
plot(x,y,'.r')
plot(x,yi)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by