Not Enough Input Arguments
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hi,
I have a formula that includes two variables T and d but whatever i try matlab gives an error saying that that T and d might be unused. I have 7 different T and d values and have to calculate 7 different output from function using matched T and d values. How can i define T and d as an input?
Here is my code without inputs,
function L=dispersion(T,d)
L=9.81*T*T/(2*pi);
Lo=0;
while abs(L-Lo)>10^-8;
Lo=L;
L=(9.81*T.^2./(2*pi))*(tanh(2*pi*d/L));
end
end
Answers (1)
Jan
on 18 Oct 2018
T = [0.5 0.5 1 1 5 5 10];
d = [0.1 0.1 0.5 0.5 5 10 50];
L = dispersion(T,d)
function L = dispersion(T,d)
L = 9.81 * T .^ 2 / (2*pi);
Lo=0;
while any(abs(L-Lo) > 1e-8)
Lo = L;
L = (9.81 * T.^2 ./ (2*pi)) .* tanh(2 * pi* d ./ L);
end
end
Using the iteration for all different T values might be inefficient. I would call the function in a for loop instead.
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!