function y = fresnelS(f,x,n)if mod(n,2) == 1 error('The number of strips must be even!'); endh = x/n; y = f(x); for k = 1:2:n y = y + 4*f(k*h); endfor k=2:2:n-1 y = y + 2*f(k*h); endy = y*h/3;
How would you modfiy this code so that x can be a vector, e.g. fresnelS(@(x) sin(x^2), [3 2 1], n)
Best Answer