Created
February 22, 2018 20:17
-
-
Save giraffesyo/73621c84df20f570298bd6906197fd54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear *; close all; clc; | |
x = [2,3,2,3]'; | |
y = [4, 6, 6, 8]'; | |
plot(x,y, '*'), hold on; | |
axis([0,4,0,10]); | |
sx = sum(x); | |
sy = sum(y); | |
sxx = sum(x.^2); | |
sxy = sum(x.*y); | |
A = [size(x, 1) sx | |
sx, sxx]; | |
B = [sy sxy]'; | |
C = A\B | |
xn = 0:0.1:10; | |
yn = C(1) + C(2)*xn; | |
plot(xn, yn); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment