Integrate multi-variable function in terms of one variable? With variables as bounds?

Hi all,
I have an objective function (written as a matlab function) I'm sending to the optimization tool , but I seem to be having trouble correctly stating it. The optimizer will plug in starting values for design variables x1 through x8, before it starts iterating.
function z = Blah(x)
f1 = @(x1) sqrt((1+(2*x(5)*x1)^2));
f2 = @(x2) sqrt((1+(2*x(6)*x2)^2));
f3 = @(x3) sqrt((1+(2*x(7)*x3)^2));
f4 = @(x4) sqrt((1+(2*x(8)*x4)^2));
z = integrate(f1,0,x(1)) + integrate(f2,x(1),x(2)) +...
integrate(f3,x(2),x(3)) + integrate(f4,x(3),x(4));
end
As you can see, I'm trying to integrate with the bounds as the design variables themselves. The integrals only need to be carried out in terms of one design variable (x1 for f1, x2 for f2 ,x3 for f3, x4 for f4) though, and integrate() doesn't give you the option to designate which variable to integrate in terms of. So, I thought stating them as new terms x1,x2,x3,x4 in f1 through 4 as opposed to x(1), x(2), x(3), x(4) would work but it does not:
"Undefined function or method 'integrate' for input arguments of type 'function_handle'."
Any ideas on how to handle such an integral? Thanks for your time.

2 个评论

Which MATLAB version are you using? integrate() is relatively new.
R2011a (Version 7.12) - 8 Apr 2011
Do you think I should try a previous numerical integrator? Is something like quadgk() an older one?

请先登录,再进行评论。

回答(1 个)

"integrate" was not available in R2011a. You need to use something like quadgk() or as appropriate taking into account the continuity of your functions and whether you need to integrate to infinity or not.

类别

提问:

Red
2013-5-3

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by