Advertisement
razdady212

Copii

Apr 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. copii = dlmread('copii.txt');
  2. n = rows(copii);
  3. inaltime = copii(:,1);
  4. greutate = copii(:,2);
  5. varsta = copii(:,3);
  6. #subplot(1,1,1);
  7.  
  8. plot(inaltime,greutate,'ro');
  9. title('Dependenta dintre inaltime si greutate');
  10. xlabel('Inaltime [m]');
  11. ylabel('Greutate [kg]');
  12. printf('coeficientul de corelatie intre inaltime si greutate : %f \n',corr(inaltime,greutate));
  13.  
  14. x = inaltime;
  15. y = greutate;
  16. beta1 = (sum(x)*sum(y)-n*sum(x.*y))/(sum(x)*sum(x)-n*sum(x.*x));
  17. beta0 = (sum(x)*sum(x.*y)-sum(x.*x)*sum(y))/(sum(x)*sum(x)-n*sum(x.*x));
  18.  
  19. printf('\n Coef. de regresit: %f\n',beta1);
  20. printf('\n Interceptia: %f\n',beta0);
  21. hold on;
  22. t = linspace(1.1,2.0,5);
  23. title('Regresia liniara simpla');
  24. plot(t,beta1*t+beta0,'-r');
  25. grid;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement