Here's what I have so far
function [ I ] = myTrapz2D( f, x0, xn, y0, yn, nx, ny ) dx = (xn - x0)/nx;dy = (yn - y0)/ny;i = 1;sumx = zeros(nx,1);sumy =zeros(ny,1); while i < nx xi = x0 + i*dx; sumx(i) = f(xi); i = i+1;endsumx = sum(sumx);Ix = ((dx)/2)*(f(x0)+f(xn)+(2*sumx));fd = Ix(y); while i < ny yi = y0 + i*dy; sumy(i) = fd(yi); i = i+1;endsumy = sum(sumy); I =((dy)/2)*(fd(y0)+fd(yn)+(2*sumy)); end
not sure if it's correct at all but it has to be solved using some variation of the equation for I that I used. I keep getting an error that there aren't enough input arguments. There are my input arguments: f = @(x,y) x.^2 – (2*y.^2) + (x.*y.^3); x0 = 0; xn = 2; y0 = -1; yn = 1; nx = 8; ny = 8;
Best Answer