You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

a) og b)

function result = trapes(a,b,N,f)
result = 0;
h = (b-a)/(N-1);
for i = 0:N-1
    r = f(h*i+a);
    s = f((i+1)*h+a);
    result = result +  trapezArea(r,s,h);
end
end
function A = trapezArea(r,s,h)
A = (r+s)*h/2;
end
  • No labels