How to solve the dispersion relation in a symbolic expression?

6 次查看(过去 30 天)
I have a symbolic expression along the lines:
H = @(f) a*k*f;
where a is a constant. f is the rotational frequency and k is the wave number, which are connected through the dispersion relation:
f^2 = g*k*tanh(k*S)
where g = 9.81 is the gravitational constant and S = 20 is the water depth. I would like to plot H(f), how can I evaluate the non-linear expression k=k(f) within the symbolic expression?
Many thanks.

采纳的回答

Mischa Kim
Mischa Kim 2014-4-14
编辑:Mischa Kim 2014-4-14
Hello László, what about
g = 9.81; S = 20; a = 1;
H = @(k) a*k.*sqrt(g*k.*tanh(k*S));
k = -2:0.1:2;
plot(k,H(k))
Of course, you can first define H and f separately, if you need/want to.
  2 个评论
László Arany
László Arany 2014-4-14
编辑:László Arany 2014-4-14
That is a great workaround again, many thanks. In this actual case I can change the variable to k indeed.
But is it impossible to solve such an expression within a symbolic function? I mean if the expression was something like
H = @(f) f*k;
with the following relationship between the two variables:
f * tanh(f) = k * tanh(k)
then you wouldn't be able to bring the expression to the form f = f(k) or k = k(f) and then this solution wouldn't work. Is it possible to solve the non-linear expressions with e.g. fsolve or something else within the symbolic expression in such cases?
Mischa Kim
Mischa Kim 2014-4-14
I don't think I follow. Are you trying to solve a nonlinear equation of the form H(f) = 0 using anonymous functions? If so, simply define H as shown above and then use fsolve(H,f0), where f0 is the starting guess.

请先登录,再进行评论。

更多回答(0 个)

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by