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 个评论
Walter Roberson
2013-5-3
Which MATLAB version are you using? integrate() is relatively new.
Red
2013-5-3
回答(1 个)
Walter Roberson
2013-5-3
0 个投票
"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.
类别
在 帮助中心 和 File Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!