Finding maximum to a symbolic array inside an m-file
1 view (last 30 days)
Show older comments
Hi everyone,
I'm using MATLAB to graphically display a model with three variables, L1, L2 and Psi. I have created the following function:
function d = dafstand(L1,L2)
%do a lot of stuff, with the result being a 1- or 2-dimensional complex vector, called x, containing a symbolic Psi
Now, for this variable x, I want to elementwise maximize x given a Psi between 0 and pi/2 (for example, using fminbnd with -x). When such a Psi is given, the complex part of the vector results to 0, and I would like to drop that using something like real(). Finally, I want to get the maximum element in x, such that the last line of the m-file would be:
d = max(x)
So that I can call from the command window:
ezsurf(@(L1,L2)(dafstand(L1,L2)),[0,1,0,1]
Can someone help me?
0 Comments
Answers (1)
Walter Roberson
on 14 Dec 2011
If the symbolic formula are sufficiently complex, then fminbnd would not always be able to find the correct maximum, especially if there are discontinuities.
There is a possibility that you might find it more productive to solve() or fsolve() for the imaginary part being 0, since that is what you care about anyhow.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!