1
我正在Matlab中工作,我写了下面的脚本,目的是导入到Excel中,但是当我运行Matlab C++编码器时,它告诉我我的内联命令不受支持。将matlab内联命令转换为不同
function f = moody(ed,Re)
if Re<0
error(fprintf('Reynolds number = %f cannot be negative',Re));
elseif Re<2000
f = 64/Re; return % laminar flow
end
if ed>0.05
error(fprintf('epsilon/diameter ratio = %f is not on Moody chart',ed));
end
findf = inline('1.0/sqrt(f)+2.0*log10(ed/3.7+2.51/(Re*sqrt(f)))','f','ed','Re');
fi = 1/(1.8*log10(6.9/Re+(ed/3.7)^1.11))^2; % initial guess at f
dfTol = 5e-6;
f = fzero(findf,fi,optimset('TolX',dfTol,'Display','off'),ed,Re);`
我如何重写使用匿名函数或arrayfun命令,这样编译器将工作findf = inline
命令?