An x close to zero is psi(0)-log(0), which is NaN and would result in an error from fzero. I used max(x,realmin) to ensure that x never gets too small (as long as the the initial guess for fzero is large enough, it may not be needed). Using fzero and the numeric version of psi: f = fzero(f,1) This is not a bad option as long as you're assuming that x is real and positive. Otherwise, you'll have to solve this equation numerically ( solve gives an answer in terms of a number anyways). ![]() ![]() If the above works, then you can call a vectorized version of the symbolic psi with: psisym = char(sym(x)) ',psi)']) The following code checks for licenses for the entire list above: index cellfun ( (f) license test, f), featureStr) availableFeatures featureStr (logical (index)) However, the above just confirms that the license. I don't guarantee that it will work, but you can try this: x = evalin(symengine,'float(solve(psi(x)-log(x/5),x))')īy the way, you may wish to consider setting assumptions – the x returned is different if you specify syms x real as the equation has multiple roots. Using the above list of feature strings and the function license, you can check which toolboxes you have a license to use. First, although you can't call psi for symbolic inputs, it's possible that the symbolic engine in R2011a still knows about this function. ![]() If you can't upgrade, here are two things to try. The sym/psi function was added to the Symbolic Math toolbox in Matlab version R2011b so it's not a surprise that you can't get it to work in R2011a.
0 Comments
Leave a Reply. |