[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Synonym
From: |
John W. Eaton |
Subject: |
Re: Synonym |
Date: |
Wed, 8 Apr 2020 12:07:13 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
On 4/8/20 11:46 AM, "Markus Mützel" wrote:
I don't think it is necessary to initialize varargout. It should be initialized
to the correct length. [1]
This should be enough:
function varargout = short (varargin)
[varargout{:}] = verylongname (varargin{:});
endfunction
Can you verify that this function actually works in Matlab (see below
for simple example)?
[1]: https://de.mathworks.com/help/matlab/ref/varargout.html
The example on this page uses
[varargout{1:nargout}] = ...
which does work in Octave. But
[varargout{:}] = ...
fails in Octave unless varargout is explicitly initialized.
And there is another example on that page that shows this:
function varargout = variableNumInputAndOutput(varargin)
disp(['Number of provided inputs: ' num2str(length(varargin))])
disp(['Number of requested outputs: ' num2str(nargout)])
If varargout is initialized when the function is called, then why use
length (varargin) instead of nargin and nargout instead of length
(varargout)?
Can you try the following in Matlab to verify that varargout is initialized?
function varargout = xsvd (varargin)
numel (varargin)
numel (varargout)
[varargout{:}] = svd (varargin{:});
end
and then call it with
xsvd (rand (2))
s = xsvd (rand (2))
[u, s, v] = xsvd (rand (2))
Does that work? If so, I'll fix Octave to match that behavior.
jwe
Re: Synonym, John W. Eaton, 2020/04/08
- Re: Synonym, Ian McCallion, 2020/04/08
- Re: Synonym, Doug Stewart, 2020/04/08
- Re: Synonym, Markus Mützel, 2020/04/08
- Re: Synonym,
John W. Eaton <=
- Re: Synonym, Tony Richardson, 2020/04/08
- Re: Synonym, John W. Eaton, 2020/04/08
- Re: Synonym, Thomas D. Dean, 2020/04/08
- Re: Synonym, Kai Torben Ohlhus, 2020/04/09
- Re: Synonym, Thomas D. Dean, 2020/04/09
Re: Synonym, Markus Mützel, 2020/04/08