[Scilab-users] varargout doubt

Samuel Gougeon sgougeon at free.fr
Tue Nov 8 20:41:48 CET 2016


Hello Shamika,

When we call a function defined with several output variables (either 
with a list of named argout, or with varargout),
a simple call like callOctave(fname,varargin)with no explicit assignment 
always returns only the first argout. To get next argout, they must be 
explicitly assigned like in:
[a,b,c] = callOctave(fname,varargin)


Le 08/11/2016 06:47, Shamika Mohanan a écrit :
> Hello,
>
> I have a function defined as such
>
> function varargout= callOct(fname,varargin)
>     varargout=list(callOctave(fname,varargin))
> endfunction
>
> When I call this function with [c,d]=callOct("butter",8,0.1), I get 
> the error
> !--error 21
> Invalid index.
It's normal: callOctave(fname,varargin) returns only its first argout. 
So list(callOctave(...)) has only one component and varargout is limited 
to this one, while with
[c,d]=callOct("butter",8,0.1)
you try to get in d a second argout -- that does not exist: => error
>
> If I call the function as c=callOct("butter",8,0.1),I get no 
> error.varargout stores only one o/p argument even though callOctave 
> returns two arguments.
>
> If I remove varargout like this
>
> function [b,a]=callOct(fname,varargin)
>     [b,a]=callOctave(fname,varargin)
> endfunction
>
> Now when I call this function with [c,d]=callOct("butter",8,0.1), I 
> get no error.
>
> I need callOct function to work with any number of output arguments 
> and so I need to use varargout. How do I get the function to work with 
> varargout?
.
To answer, you must provide information about how you define 
callOctave(fname,varargin):
Does it use also varargout, or not?

Regards
Samuel Gougeon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20161108/69577d2d/attachment.htm>


More information about the users mailing list