[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: number of arguments if nargout meets nargin (was Re: plot templates
From: |
John W. Eaton |
Subject: |
Re: number of arguments if nargout meets nargin (was Re: plot templates and options lists for set, plot etc.) |
Date: |
Sun, 7 Jun 2009 08:53:54 -0400 |
On 6-Jun-2009, Benjamin Lindner wrote:
| Thorsten Meyer wrote:
| > Benjamin Lindner wrote:
| >>> Also, I would like to wrap this transformation into a function. I
| >>> tried it like
| >>> this (in octave compiled from the current tip):
| >>>
| >>> function varargout = struct2options (structure)
| >>> varargout = {fieldnames(structure)'{:}; struct2cell(structure)'{:}};
| >>> nargout
| >>> endfunction
| >>>
| >> this should read
| >>
| >> function c = struct2opt(s)
| >> c = reshape(cat(2, fieldnames(s), struct2cell(s)).',1,[]);
| >> endfunction
| >>
| >> then
| >> plot(1:5, 5:-1:1, struct2opt(style){:})
| >> should work
| > Yes, that is a way how to do it. However, I would like to eliminate the
| > {:} part :-)
| >
| > Also, the more general question is interesting to me: can I somehow
| > control how many arguments are passed in this nested function call:
| > function1(function2())
| > if function 2 has varargout and function 1 has varargin
| >
|
| I don't know a way to control this, so I stick to the {:} suffix :)
| But yes, I agree that this is the fundamental question behind it.
| Sorry I cannot offer a solution...
No, there is no way to do what you want. When Octave evaluates a
function in an argument list, nargout is set to 1 for the function
call. I see no other reasonable thing to do.
jwe
- Re: plot templates and options lists for set, plot etc., (continued)
- Re: plot templates and options lists for set, plot etc., Ben Abbott, 2009/06/06
- Re: plot templates and options lists for set, plot etc., Thorsten Meyer, 2009/06/06
- Re: plot templates and options lists for set, plot etc., John W. Eaton, 2009/06/07
- Re: plot templates and options lists for set, plot etc., Ben Abbott, 2009/06/07
- Re: plot templates and options lists for set, plot etc., John W. Eaton, 2009/06/07
Re: plot templates and options lists for set, plot etc., Benjamin Lindner, 2009/06/06