SHARE
TWEET

Untitled

a guest Apr 24th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function [s]=prostokat(a,b,f)
  2.     s=0;
  3.     st=0;
  4.     n=5;
  5.     xd = (b-a)/n;
  6.     X=[a:xd:b];
  7.     for i = a:length(X)-1;
  8.         x1=a+i*xd;
  9.         st=st+f(x1-xd/2);
  10.         if(i<n)
  11.             s=s+f(x1);
  12.         end
  13.     end
  14.     s=(xd/6)*(f(a)+f(b)+2*s+4*st);
  15.     return;
  16. end
  17.  
  18. % function [s]=prostokat(a,b,f)
  19. %     s=0;
  20. %     n=1000;
  21. %     xd = (b-a)/n;
  22. %     X=[a:xd:b];
  23. %     for i = a:length(X)-1;
  24. %         s=s+f(a+i*xd);
  25. %        
  26. %     end
  27. %     s=(s+(f(a)+f(b))/2)*xd;
  28. %     return;
  29. % end
  30.  
  31. % function s=prostokat(a,b,f)
  32. %     s =0;
  33. %     n=10000;
  34. %     xd = (b-a)/n;
  35. %     i=1;
  36. %     while(i < n)
  37. %         s=s+f(a+i*xd);
  38. %         i=i+1;
  39. %     end
  40. %     s=(s+(f(a)+f(b))/2)*xd;
  41. %     return;
  42. % end
  43.  
  44. % function s=prostokat(a,b,f)
  45. %     s =0;
  46. %     n=10000;
  47. %     xd = (b-a)/n;
  48. %     i=1;
  49. %     while(i <= n)
  50. %         s=s+f(a+i*xd);
  51. %         i=i+1;
  52. %     end
  53. %     s=s*xd;
  54. %     return;
  55. % end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top