Newbie question using solve
Show older comments
Hi, I am really a newbie in using matlab and have a problem solving a mathematical model. How can I make this work in MATLAB?
Bi = 0.43;
t = -16.9;
N = x/(2*Bi)+ t/2;
y = 2*(1-coth(x))*(cosh(x)-cosh(N)) + ...
x/((2*Bi)*exp(-N))+(1-coth(x)/(2*Bi))*x*sinh(x);
P = solve(y);
M = P/(2*Bi)+t/2;
C = (P^2/sinh(P)^2)*exp(-M)*(cosh(P)-cosh(M));
??? Error using ==> map>checkstat at 29
Error: argument must be of 'Type::Arithmetical' [sinh]
Error in ==> map at 15
checkstat(result,status,nargout);
Error in ==> sym.sinh at 9
Y = map(X,'sinh');
Thanks in advance
5 Comments
Andrew Newell
on 7 Apr 2011
Hi, newbie. Can you please edit your question (click on "edit") and format your code so it is readable? Put just one command on each line and indent by two spaces (so the code looks grey in the preview window).
Matt Tearle
on 7 Apr 2011
What is x? Is it symbolic or numeric? Or perhaps a better question: what are you actually trying to do? Solve y for what?
benjamin
on 7 Apr 2011
Matt Tearle
on 7 Apr 2011
Yes, I got that much from the code. What I'm trying to understand is your intent. What does "solve the equation y to x" mean? Are you trying to solve y(x) = 0 for x, or *invert* the expression y(x) (to get x(y))? The solve function will find x such that y = 0, then P will be that x value. Assuming that's what you want, if I add "syms x" at the beginning, your code works fine. So what is x, how is it created? Can you do "whos x" and report the result.
benjamin
on 7 Apr 2011
Answers (2)
Walter Roberson
on 7 Apr 2011
0 votes
y is highly unstable numerically. You would have to push the symbolic toolbox to somewhere past 50 decimal places to find the zero between 35.571688344555791899140414695 and 35.571688344555791899140414696 (there is a difference of approximately 10^92 between those two points.)
The root near 2.5451437638625637590284940922858247397328944979967 is easy to find, but any other roots are not. I have not been able to determine whether there are additional roots.
benjamin
on 9 Apr 2011
0 votes
4 Comments
Walter Roberson
on 9 Apr 2011
Are you looking for a numeric solution or an algebraic solution? If you are looking for a numeric solution then use matlabFunction to convert y to a MATLAB function from a symbolic function, and then use fzero() on the result.
benjamin
on 12 Apr 2011
Walter Roberson
on 12 Apr 2011
YM = matlabFunction(y);
P = fzero(YM,3); %3 is the initial guess
Be warned, though, that the function is highly unstable numerically, and that you may have trouble determining a useful solution in double precision.
benjamin
on 12 Apr 2011
Categories
Find more on Conversion Between Symbolic and Numeric in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!