我一直在尝试通过fzero
在 MATLAB 中使用来解决这个隐式方程。保存代码的文件被命名为"colebrook"
,到目前为止我输入的内容如下。
D = input('Please enter the pipe diameter in meters: ');
V = input('Please enter the fluid velocity in m/s: ');
rho = input('Please enter fluid density in kg/m^3: ');
mew = input('Please enter fluid viscosity in kg/m*s: ');
Re = D*V*rho/mew;
eps = input('Enter absolute roughness in milimeters: ');
eD = eps/(D*1000);
a = fzero(colebrookfunc,0.1);
fprintf(a);
我要求解的方程保存在另一个名为 的 m 文件"colebrookfunc"
中,其中包含的代码如下。
function F = colebrookfunc(x)
F = x - 1./(-4 * log10(eD/3.7 + 1.256./(Re*x.^0.5))).^2;
当我运行时,我收到此错误:
??? Input argument "x" is undefined.
Error in ==> colebrookfunc at 2
F = x - 1./(-4 * log10(eD/3.7 + 1.256./(Re*x.^0.5))).^2;
Error in ==> colebrook at 28
a = fzero(colebrookfunc,0.1);
我的错误是什么?
谢谢你。