在倍频程中运行Matlab脚本时,打印使用和fzero错误
我试图在Octave-5.1.0.0中运行inputfile\u calrel\u example1 FERUM Matlab脚本,但在打印使用和fzero方面遇到错误,如下所示:在倍频程中运行Matlab脚本时,打印使用和fzero错误,matlab,octave,Matlab,Octave,我试图在Octave-5.1.0.0中运行inputfile\u calrel\u example1 FERUM Matlab脚本,但在打印使用和fzero方面遇到错误,如下所示: error: Invalid call to fzero. Correct usage is: -- fzero (FUN, X0) -- fzero (FUN, X0, OPTIONS) -- [X, FVAL, INFO, OUTPUT] = fzero (...) error: called from
error: Invalid call to fzero. Correct usage is:
-- fzero (FUN, X0)
-- fzero (FUN, X0, OPTIONS)
-- [X, FVAL, INFO, OUTPUT] = fzero (...)
error: called from
print_usage at line 91 column 5
fzero at line 133 column 5
drho0_dthetaf_integral at line 75 column 22
mod_corr_solve at line 99 column 54
form at line 90 column 58
ferum at line 129 column 33
>>
error ("Octave:invalid-fun-call", msg);
查看print_usage.m文件,第91行显示如下:
error: Invalid call to fzero. Correct usage is:
-- fzero (FUN, X0)
-- fzero (FUN, X0, OPTIONS)
-- [X, FVAL, INFO, OUTPUT] = fzero (...)
error: called from
print_usage at line 91 column 5
fzero at line 133 column 5
drho0_dthetaf_integral at line 75 column 22
mod_corr_solve at line 99 column 54
form at line 90 column 58
ferum at line 129 column 33
>>
error ("Octave:invalid-fun-call", msg);
而第78至92行:
if (at_toplev)
error ("Octave:invalid-fun-call",
"Invalid call to %s. Correct usage is:\n\n%s\n%s",
name, usage_string, __additional_help_message__ ());
else
msg = sprintf ("Invalid call to %s. Correct usage is:\n\n%s",
name, usage_string);
## Ensure that the error doesn't end up with a newline, as that disables
## backtraces.
if (msg(end) == "\n")
msg(end) = " ";
endif
error ("Octave:invalid-fun-call", msg);
endif
和fzero行132至134如下所示:
if (nargin < 2 | nargin > 3)
print_usage (mfilename ());
end
if(nargin<2 | nargin>3)
打印使用(mfilename());
结束
我想就如何解决上述错误消息提供一些提示
致意
Aliyu Aziz如评论中所述,
fzero
是通过以下参数调用的
drho0_dthetafi.mu = fzero( ...
'betadrho0_dthetaf' ...
, 0 ...
, optimset('fzero') ...
, dF_dthetafi.mu ...
, PHI2 ...
, F ...
, dPHI2_dZi ...
, dZi_dthetafi.mu ...
, dPHI2_drho0 ...
, detJ ...
, WIP ...
);
从文档(help fzero
)中,您可以看到上述调用不是有效的fzero
调用:
如您所见,“optimset”后面的额外参数会触发一个错误
我假设额外的参数是用于betadrho0\u dthetaf
函数的参数。通常,函数FUN需要一个参数(因为它是单变量的)。如果您的betadrho0\u dthetaf
函数需要许多其他参数,则不要通过字符串在fzero中使用它,而是将其环绕在只接受单个参数的匿名函数句柄周围,并在内部使用您想要的函数来计算想要的结果,例如
drho0_dthetafi.mu = fzero( ...
@(x) betadrho0_dthetaf( ...
x ...
, dF_dthetafi.mu ...
, PHI2 ...
, F ...
, dPHI2_dZi ...
, dZi_dthetafi.mu ...
, dPHI2_drho0 ...
, detJ ...
, WIP ...
) ...
, 0 ...
, optimset('fzero') ...
);
或者类似的东西,取决于你如何调用beta函数。你/脚本是如何调用
fzero
``drho0_dthetafi.mu=fzero('betadrho0_dthetaf',0,optimset('fzero'),dF_dthetafi.mu,PHI2,F,dPHI2_dZi,dZi_dthetafi.mu,dPHI2_drho0,detJ,WIP)```fzero由drho0_dthetaf_integral在第75行第22列调用,如上图所示。非常感谢塔索斯,这帮助我跨越了障碍。@AliyuA.Aziz我很高兴。如果答案是您问题的解决方案,请将其标记为已接受。(如果没有,请随意创建另一个包含详细信息的答案,以方便未来用户)!。