views:

169

answers:

3

Does anyone know how to minimize a function containing an integral in MATLAB? The function looks like this:

L = Int(t=0,t=T)[(AR-x)dt], A is a system parameter and R and x are related through:  
dR/dt = axRY - bR, where a and b are constants.  
dY/dt = -xRY

I read somewhere that I can use fminbnd and quad in combination but I am not able to make it work. Any suggestions?

+1  A: 

Perhaps you could give more details of your integral, e.g. where is the missing bracket in [AR-x)dt]? Is there any dependence of x on t, or can we integrate dR/dt = axR - bR to give R=C*exp((a*x-b)*t)? In any case, to answer your question on fminbnd and quad, you could set A,C,T,a,b,xmin and xmax (the last two are the range you want to look for the min over) and use:

 [x fval] = fminbnd(@(x) quad(@(t)A*C*exp((a*x-b)*t)-x,0,T),xmin,xmax)

This finds x that minimizes the integral.

Ramashalanka
Ah... I thought I added a second equation as well. I apologize for that... Will add the second one in a second. Thanks for the pointers, I will currently look into that. However, I am curious how your answer might change for my revised question...
Legend
+1  A: 

If i didn't get it wrong you are trying to minimize respect to t:

\int_0^t{(AR-x) dt}

well then you just need to find the zeros of:

AR-x

This is just math, not matlab ;)

Mascarpone
Thanks... Would you mind fixing the latex in your post? I don't seem to be able to see it for some reason...
Legend
unfortunately texify doesn't support external linking. Past the code here http://www.texify.com/links.php to see the image.
Mascarpone
A: 

Here's some manipulation of your equations that might help.

Combining the second and third equations you gave gives

dR/dt = -a*(dY/dt)-bR

Now if we solve for R on the righthand side and plug it into the first equation you gave we get

L = Int(t=0,t=T)[(-A/b*(dR/dt + a*dY/dt) - x)dt]

Now we can integrate the first term to get:

L = -A/b*[R(T) - R(0) + Y(T) - Y(0)] - Int(t=0,t=T)[(x)dt]

So now all that matters with regards to R and Y are the endpoints. In fact, you may as well define a new function, Z which equals Y + R. Then you get

L = -A/b*[Z(T) - Z(0)] - Int(t=0,t=T)[(x)dt]

This next part I'm not as confident in. The integral of x with respect to t will give some function which is evaluated at t = 0 and t = T. This function we will call X to give:

L = -A/b*[Z(T) - Z(0)] - X(T) + X(0)

This equation holds true for all T, so we can set T to t if we want to.

L = -A/b*[Z(t) - Z(0)] - X(t) + X(0)

Also, we can group a lot of the constants together and call them C to give

X(t) = -A/b*Z(t) + C

where

C = A/b*Z(0) + X(0) - L

So I'm not sure what else to do with this, but I've shown that the integral of x(t) is linearly related to Z(t) = R(t) + Y(t). It seems to me that there are many equations that solve this. Anyone else see where to go from here? Any problems with my math?

Justin Peel