0
votes

How can 1/ln(x) be integrated in Matlab?

y=0:.1:1;
a=log(y);
plot(a,y);
z=quad(a,-2,2);

I thought this would work.

1
I don't see any integration there, and it looks like you've passed the independent and dependent variable to plot in the wrong order. - Ben Voigt
matrixlab-examples.com/definite-integrals.html I tried it with q = quad(FUN, A, B) - Speed
But a is a variable, not a function. - Ben Voigt

1 Answers

1
votes

This works for me:

z = quad(@(x) 1./log(x), 2, 10)

and gives the result

z = 5.1204

You can't integrate across the interval -2:2, because the natural logarithm is undefined at x = 0, and at x = 1, the natural logarithm is 0, so the reciprocal isn't defined.