I need help understing what to do here,
I know i need to slobe for p1 and p2x but stuck, I have the code below but just stuck.
y(๐‘ฅ)=๐‘1+๐‘2๐‘ฅ
where
x = 0:0.1:20;
noise =?? % a number, to define
y= 4*x + noise*rand(1,length(x));
Vary the value for noise as 0, 50 and 100 to get three different results for ๐‘1and ๐‘2,
From a linear algebra standpoint, determine the coefficients, ๐‘1and ๐‘2, of the least-squares-regression of a line fit through the data defined above.
thank you

๋‹ต๋ณ€ (1๊ฐœ)

KSSV
KSSV 2020๋…„ 9์›” 14์ผ

0 ๊ฐœ ์ถ”์ฒœ

Read about polyfit. If you have the data x, y you can fit a line and get p1, p2 using polyfit.
p = polyfit(x,y,1) ;
p1 = p(1) ; p2 = p(2) ;

์นดํ…Œ๊ณ ๋ฆฌ

๋„์›€๋ง ์„ผํ„ฐ ๋ฐ File Exchange์—์„œ Linear and Nonlinear Regression์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

์งˆ๋ฌธ:

2020๋…„ 9์›” 14์ผ

๋‹ต๋ณ€:

2020๋…„ 9์›” 14์ผ

Community Treasure Hunt

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

Start Hunting!

Translated by