Not Enough Input Arguments
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
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
回答(1 个)
Jan
2018-10-18
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.
0 个评论
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!