Advertisement
VuGal

Aproksymacja nieliniowa

Feb 5th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.43 KB | None | 0 0
  1. function mojaapro(x,y)
  2.  
  3. %dane od Sypki: x [0 5]    y [0 2]
  4.  
  5. figure
  6. plot(x,y,'b*')
  7. grid on
  8.  
  9. % f(x)=A*(1-e^(-Bx))
  10. constant = lsqcurvefit(@funapro, [0.5;0.25], x, y);
  11.  
  12. A = constant(1)
  13. B = constant(2)
  14.  
  15. xfit = 0:0.1:5;
  16. yfit = funapro(constant,xfit);
  17.  
  18. figure
  19. plot(x,y,'b*')
  20. hold on
  21. plot(xfit,yfit,'r','linewidth',2)
  22. grid on
  23.  
  24. end
  25.  
  26. function y = funapro(constant,x)
  27.  
  28. y = constant(1)*(1-exp(((-1)*constant(2)*x)));
  29.  
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement