Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problems using integral function in Matlab

  1. Jan 11, 2013 #1
    Hi there!

    i have this function handle:

    integrando= @(x,landa,t) 1-exp(-((1/(landa*t))*((exp(-landa*x)/x)+((x-x0).*(1+landa*x0)-x0)*(exp(-landa*x0)/(x0^2)))));

    which as you can see using

    fplot(@(x) integrando(x,3,0.00063),[0 1.1225])

    its value is constant (actually 1, and then starts decreasing exponentially until drops to zero at 1.1225). Landa and t are parameters that change the curvature of this drop. Since this is a positive and finite function, I'm waiting a positive integral. However, integrating this same function on this same interval, I get negative figures!

    >> q1=integral(@(x) integrando(x,3,0.00063),0,1.1225)

    q1 =


    This is getting me nuts! I would very much appreciate any help. Thanks in advance!
  2. jcsd
  3. Jan 11, 2013 #2


    User Avatar
    Gold Member

    What value are you using for x0?

    I used 2 just to see if the code works, and I got:

    integrando= @(x,landa,t) 1-exp(-((1/(landa*t))*((exp(-landa*x)/x)+((x-2).*(1+landa*2)-2)*(exp(-landa*2)/(2^2)))));

    fplot(@(x) integrando(x,3,0.00063),[0 1.1225])

    q1=integral(@(x) integrando(x,3,0.00063),0,1.1225)

    q1 =

  4. Jan 12, 2013 #3
    hi kreil,

    I'm using x0=1.1225 ,which is the same value as the limit of integration. If you try again using that value on 'integrando', you'll see the result of the integral is a negative number which doesn't make any sense to me
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Problems using integral function in Matlab