[Scilab-users] ignore function output variable

Rafael Guerra jrafaelbguerra at hotmail.com
Thu Nov 10 13:17:36 CET 2016


Hi,

Concerning 'unique', without rewriting it from scratch to output only what you want when you want it, a quick & dirty workaround would be to wrap it in your own 'my_unique' function as follows:

// START OF EXAMPLE
function varargout = my_unique(a,varargin)
    [lhs,rhs] = argn();
    n = 1;
    if rhs ==2 then
        n = varargin(1);
    end
    [p,q] = unique(a);
    if n==1 then varargout(1)  = p;
    elseif n==2 then varargout(1) = q;
    end
    if lhs==2 then
        varargout(1) = p;
        varargout(2) = q;
    end
endfunction


-->a = [ 0 1 0 1 1];
-->my_unique(a)
 ans  =
    0.    1.  

-->my_unique(a,2)
 ans  =
    1.    2.  
 
-->[b,c]=my_unique(a)
 c  =
    1.    2.  
 b  =
    0.    1.  
// END OF EXAMPLE


PS: yes, it is only makeup but humans spend tons of money on that sort of thing.

Regards,
Rafael


-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of christophk
Sent: Tuesday, November 08, 2016 12:56 PM
To: users at lists.scilab.org
Subject: [Scilab-users] ignore function output variable

Hey there,
is there any way in Scilab to ignore a function output variable? I did a a
quick search in the mailing list archive and on the internet but couldn't
find anything.

Example:
a = [ 0 1 0 1 1];

// working usual function call and throwing away b in Scilab
[b,c] = unique(a);
clear b;

// Matlab syntax for ignoring output variable "b":
[~,c] = unique(a); //throws an error - is there a way of excluding "b" upon
function call in Scilab?






More information about the users mailing list