Newbie question using solve
이전 댓글 표시
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
Andrew Newell
2011년 4월 7일
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
2011년 4월 7일
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
2011년 4월 7일
Matt Tearle
2011년 4월 7일
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
2011년 4월 7일
답변 (2개)
Walter Roberson
2011년 4월 7일
0 개 추천
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
2011년 4월 9일
0 개 추천
댓글 수: 4
Walter Roberson
2011년 4월 9일
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
2011년 4월 12일
Walter Roberson
2011년 4월 12일
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
2011년 4월 12일
카테고리
도움말 센터 및 File Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!