Programming/MATLAB
Second order regression
_Sudal
2019. 3. 19. 05:45
clear all; close all; x = [-3 -1 1 3]; y = [1.3 1.5 1.4 1.2]; G = ones(length(x),3); G(:,2) = x'; G(:,3) = x'.^2; beta = (G'*G)\G'*y'; A = beta(1); B = beta(2); C = beta(3); scatter(x,y,'filled') hold on x = linspace(-3,3); plot(x,A + B*x + C*x.^2)
Figure: