I am trying to find the wavelength of wave and am unsure as to what this function tells me
8 views (last 30 days)
Show older comments
%%%%% Getting the value of L %%%%%
con = 1;
l(con) = 0;
l(con+1) = 1.56 * T ^ 2;
while abs( l(con+1) - l(con) )>0.0001
l(con+2) = ( ( 9.81 * T ^ 2 ) / ( 2 * pi ) ) * tanh( ( 2 * pi * d ) / l(con+1) );
r = l(con+1) - l(con);
con = con + 1;
end
L = l(con);
1 Comment
Answers (1)
Arjun
on 23 Apr 2025
I see that you have a piece of code and you are unsure of what it calculates.
The function can be better defined as follows:
%%%%% Getting the value of L %%%%%
function [L] = wavelength(T,d)
con = 1;
l(con) = 0;
l(con+1) = 1.56 * T ^ 2;
while abs( l(con+1) - l(con) )>0.0001
l(con+2) = ( ( 9.81 * T ^ 2 ) / ( 2 * pi ) ) * tanh( ( 2 * pi * d ) / l(con+1) );
r = l(con+1) - l(con);
con = con + 1;
end
L = l(con);
end
disp(wavelength(10,15));
The function determines the wavelength of water waves based on the dispersion relation. It takes two inputs: "T" (wave period) and "d" (water depth). Starting with an initial estimate, the function iteratively updates the wavelength using the dispersion relation within a while loop. This process continues until the difference between consecutive estimates is less than or equal to 0.0001. Once this convergence criterion is satisfied, the loop ends and the final value is returned as the wavelength. For more information, you can explore the dispersion relation for water waves online, which explains how wavelength (L) depends on wave period (T) and water depth (d).
I hope this helps!
0 Comments
See Also
Categories
Find more on Matrix Indexing 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!