0

How can i make the limits of integration scalars?

y = rand(150000,1);

x = rand(150000,1);

u=y.^x;

v=y;

z = quad(@(u) 1./log(v),0,u);

Error using quad (line 70) The limits of integration must be scalars.

Error in lnplot (line 5) z = quad(@(u) 1./log(v),0,u)

Speed
  • 27
  • 4

1 Answers1

0

Your problem is that u is a vector with length 150000 (as you are doing element-by-element multiplication in u=y.^x).

The integration limit must be a scalar, but 'u' is a matrix. You need to determine which fixed value the integration runs to.

The scalar value depends on your data set.

ThomasKJDK
  • 367
  • 1
  • 7
  • 17
  • Right, so i need to figure out a way to plot 1./log(x) from 0 to u while 0 < u < 1. How can i implement code that will replace u with a fixed value from the randomized matrix? – Speed Apr 13 '12 at 05:37
  • If you just want a random number from the matrix u, you could use: u(rand(1)), which will give you a random number. – ThomasKJDK Apr 13 '12 at 07:33
  • like this z=quad(@(u) 1./log(y),0,u(rand(1)))? – Speed Apr 13 '12 at 19:06
  • I think you will get an error because rand(1) isn't an integer. Try z=quad(@(u) 1.log(y),0,u(rand(floor(150000.*rand(1)))). Alternatively, as u is a set of random numbers you can just select u(1) as your upper limit. – ThomasKJDK Apr 13 '12 at 22:00