How can I plot a symbolic function or determine a finite and real starting guess for fzero?
Show older comments
Hello,
I have a very long and somewhat complicated complex function that I need to find the roots of. It is a function of "s", which is imaginary, and which I had to define as a symbol in order to work through previous steps and get the function (Functionofs). For those interested in the background math, I am trying to solve the characteristic equation from a determinant of a 4x4 matrix made from a transfer function made from the equations of motion of a beam. When I try starting guesses that I think would make sense using the fzero command, I keep getting the error "Function value at starting guess must be finite and real." I have tried the following:
1) Tried substituting values using subs(Functionofs,s,1*i) to see if I could happen upon something that would work. It just finished (after several minutes) and gave me an extremely long (output truncated) expression with fractions, etc. Does not seem to be of any use. I used simplify(ans) and got it down to a manageable (sort of) size, but it is still a symbol- can I convert this back to a decimal number or expression somehow?
2) Tried to plot Functionofs, but received an error that SYM could not be converted to DOUBLE to plot.
Does anyone have any ideas on what else I could try or how to get around these errors? I have not found a way to convert a symbol to a decimal number- is there one?
Thank you! It's a pretty interesting problem! -Kaitlin
Accepted Answer
More Answers (1)
Walter Roberson
on 5 Sep 2012
1 vote
Use vpa() to reduce the constant expressions.
Use matlabFunction() to convert a symbolic expression to a function handle.
Categories
Find more on Conversion Between Symbolic and Numeric in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!