Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = randi([0,100],1,30);
- y = randi ([0,100],1,30);
- save ("lab3")
- [a0,a1]=linear_regression(x,y);
- plot(x,y,'r*'); %points
- hold on;
- plot(x,a0+a1*x,'b'); %line
- figure()
- md1 = fitlm(x,y);
- disp(mdl.Rsquared.Adjusted)
- plotResiduals(md1)
- % Res = table2array(mdl.Residuals);
- % boxplot(Res)
- Osobny plik
- function [a0,a1]=linear_regression(x,y)
- x=x(:);
- y=y(:);
- X=[x,ones(numel(x),1)];
- a = (X'*X)\(X'*y);
- a0=a(2);
- a1=a(1);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement