在MATLAB中有可能有默认参数吗?
例如,这里:
function wave(a, b, n, k, T, f, flag, fTrue=inline('0'))
我希望真正的解决方案是波函数的一个可选参数。如果可能,正确的方法是什么?
目前,我正在尝试我在上面发布的内容,我得到了:
??? Error: File: wave.m Line: 1 Column: 37
The expression to the left of the equals sign is not a valid target for an assignment.
发布于 2010-10-09 03:04:53
您可能希望在MATLAB中使用parseparams
命令;用法如下所示:
function output = wave(varargin);
% comments, etc
[reg, props] = parseparams(varargin);
ctrls = cell2struct(props(2:2:end),props(1:2:end),2); %yes this is ugly!
a = reg{1};
b = reg{2};
%etc
fTrue = ctrl.fTrue;
https://stackoverflow.com/questions/795823
复制相似问题