Guest User

Untitled

a guest
Apr 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.33 KB | None | 0 0
  1. clc;
  2. %krok (h):
  3. h=0.01;
  4. %granice całkowania (a,b):
  5. a=2;
  6. b=8;
  7. %dziedzina funkcji:
  8. x=a:h:b;
  9. %funkcja f(x) = x^2-2x+sin(x) :
  10. y=x.^2-2*x+sin(x);
  11. %ilość kroków (n):
  12. n=length(y);
  13. %początkowe pole = 0 (s):
  14. s=0;
  15. %iteracja do wyczerpania kroków:
  16. for i=1:n-1
  17.     d=h*((y(i)+y(i+1))/2);
  18.     s=d+s;
  19. end;
  20. %wynik:
  21. s
  22. plot(x,y)
Add Comment
Please, Sign In to add comment