Help with syms function. Unable to find explicit solution
2 ビュー (過去 30 日間)
古いコメントを表示
I'm trying to solve for a variable that is on both sides of an equation.
T = 10;
h = 20;
g = -9.81;
syms L
eq = L == ((g)*(T)^2/(2*pi)) * tanh((2*pi*h)/L); % to solve for L
WL = solve(eq,L);
Wave_Length = vpa(WL);
Matlab is unable to find the explicit solution any ideas for how to fix this?
0 件のコメント
採用された回答
John D'Errico
2020 年 10 月 18 日
編集済み: John D'Errico
2020 年 10 月 18 日
Would you assume that every equation you write down hs an analytical solution? Why would you?
T = 10;
h = 20;
g = -9.81;
syms L
First, let me write the equation as an expression, instead of an equality. This way we can plot it, and then look for a zero crossing.
eq = -L + ((g)*(T)^2/(2*pi)) * tanh((2*pi*h)/L); % to solve for L
fplot(eq)
And what we see is a "function that crosses y==0 around L == 0, but as you approach L == 0, you divide by L. Therefore you have a singularity at L==0, exactly where the curve crosses zero.
No solution exists, because your expression is undefined at L == 0. So no, you cannot fix this. Nor can you solve for it. This is not a question of you not understanding how to use solve properly. It is a question of applying solve to something where no solution exists.
When something strange happens, PLOT IT!!!!!!!! Plot everything! Then when you have plotted everything you can think of, try plotting something else. And think about what you see there.
0 件のコメント
その他の回答 (1 件)
David Hill
2020 年 10 月 18 日
Graphing helps.
T = 10;
h = 20;
g = -9.81;
L=-.001:.000001:.001;
y=((g)*(T)^2/(2*pi)) * tanh((2*pi*h)./L) -L;
plot(L,y);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!