The simple answer is, you probably can't.
Think about how an optimization might work, Newton's method, for example. Given a starting interval for a variable, each point in that interval will map to a new point. But the result need not even be a contiguous interval. For example, solve for a root of the function:
Y = 4 - x^2
Clearly the solutions are +/-2.
Given an initial interval of [-0.1, 0.2], leaving the very first iteration to send points in both directions. But there is one point in that interval which causes Newton's method to diverge, so if you start at x==0, Newton will fail.
Admittedly, that is an example of a function with a poor choice of starting interval. But it shows some of the problems you can have.
But how about a different tool, perhaps fminsearch, and in 2 or more dimensions? Here, dependent upon where in an interval each variable lies, you will probably see the simplex iterations result in a completely different choice of simple, possibly flipping it differently, possibly even flipping from a different vertex. Again, fminsearch would fail, miserably.
Likewise, other optimization tools like GA will have serious problems. I can also show how tools like fzero will fail. Each optimizer would have its own variation of failure mode, but all will die an agonizing computational death.
Sorry, but it won't work.