So the fairly common solution to passing variable list of arguments into a subfunction is to pass in:
function out = foo(arg1, arg2, varargin)
% do something
out = foo2(arg1+arg2, varargin{:});
end
where varargin{:} is the comma-seperated unpacking of a cell-array.
But I run into the issue when I want to pass the variable list of arguments into a SUB-subfunction, for example
function out = foo2(arg1, varargin)
tempOut = foo3(varargin{:});
out = arg1 + tempOut; % Assuming I guarantee nargin >= 2
end
The problem that I run into is:
varargin passed into foo2: 1 x nargin cell
varargin passed into foo3: 1 x 1 cell, content: 1 x nargin cell
How do I unpack correctly so that I can pass into foo3 properly? Thanks!
foo3? Can you give a reproducible example? - Danielfoo3(varargin{:});rather thanfoo3(varargin);, I don't see howvararginwould be a "1 x 1 cell, content: 1 x nargin cell" insidefoo3. Does your actual code do other things? - horchler