Advertisement
Voldemord

[Matlab] Algorytm całkowania metodą prostokątów

Apr 24th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.22 KB | None | 0 0
  1. %ProstMethod('x^2 +4',1,6,1)
  2. %ans =    75
  3.  
  4. function [ w ] = ProstMethod( f, a, b, d)
  5. s = 0;
  6. syms x;
  7. f = eval(f);
  8. x = [a:d:b];
  9.     for i = 1:(length(x) - 1)
  10.         s = s + subs(f,x(i))*d;
  11.     end
  12. w = s;
  13. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement