Finding maximum to a symbolic array inside an m-file
Mostrar comentarios más antiguos
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?
Respuestas (1)
Walter Roberson
el 14 de Dic. de 2011
0 votos
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.
1 comentario
Sander Hermanussen
el 14 de Dic. de 2011
Categorías
Más información sobre Common Operations en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!