Finding maximum to a symbolic array inside an m-file
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2011-12-14
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.
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!