On 14.09.2012, at 15:46, Jordi Gutiérrez Hermoso <
[hidden email]> wrote:
> On 14 September 2012 09:30, Lukas Reichlin
> <
[hidden email]> wrote:
>> Currently, with
>>
>> ret1 = testfun (arg1, arg2, arg3)
>>
>> nargin is 3 and inputname ranges from 1 to 3.
>> But with
>>
>> ret2 = testfun (args{:})
>>
>> nargin is still 3 but only inputname(1) exists while inputname(2)
>> and inputname(3) give errors.
>
> But if you're passing a cs-list, the cs-list itself doesn't have the
> variable names that you want, and inputname is working as documented,
> returning an empty string.
>
>> Therefore I must find an alternative to inputname or an alternative
>> to nargin which counts input arguments the same way as inputname
>> does. Do you know how to circumvent this problem?
>
> What exactly is your actual problem? nargin still counts arguments,
> but why do you want to know what the variables are called in the
> calling function? The calling function doesn't have this information
> when you use a cs-list. To me this seems like premature closure or an
> X-Y problem:
>
>
http://www.perlmonks.org/index.pl?node_id=542341>
> Can you give broader context in order to be able to give you a better
> answer? There may be a completely differenty way to solve your broader
> problem.
>
> - Jordi G. H.
Hi Jordi
Thanks for your quick reply! The broader context is given on line 92 of MDSSystem2.m [1]
bode (G_per{:}, w)
G_per is a cell of LTI models to be plotted by bode. The bode function generates an automatic legend with the argument names given by the inputname function. On line 91 in bode.m [2]
legend_args{k} = inputname(sys_idx(k)); # watch out for bode (lticell{:})
I'm trying to get the argument names. However, only inputname(1) and inputname(2) work because bode (G_per{:}, w) has only two arguments. But since G_per contains about a dozen LTI systems, nargin = numel (G_per) + 1 (+1 because of argument w). Here inputname(n) for n>2 is failing. Therefore I need a way to find out how many inputnames were given (nargin doesn't work) so I can stop before inputname(n) fails. (counting the inputs like inputname, instead of a try-catch block)
Best regards,
Lukas
[1] MDSSystem2.m
http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/control/devel/MDSSystem2.m?revision=11015&view=markup[2] bode.m
http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/main/control/inst/bode.m?revision=11025&view=markup------------------------------------------------------------------------------
How fast is your code?
3 out of 4 devs don\\\'t know how their code performs in production.
Find out how slow your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219672;13503038;z?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev