Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
考虑一个函数varargout = foo(varargin)。我知道如何格式化逗号分隔的列表,以便我们可以varargin自动生成。例如[x y z] = ndgrid(-1:1,-1:1,-1:1)相当于:
varargout = foo(varargin)
varargin
[x y z] = ndgrid(-1:1,-1:1,-1:1)
inp = repmat({-1:1},[1 3]); [x y z] = ndgrid(inp{:});
我的问题是:如何自动获取输出(x,y,z在示例中)?IE,
x,y,z
out = ndgrid(inp{:});
PS:我想避免使用eval.
eval
看起来这应该有效:
out = cell(size(inp)); [out{:}] = ndgrid(inp{:});