[Scilab-users] Custom function takes arguments from workspace

Pablo Fonovich pablo_f_7 at hotmail.com
Fri Apr 10 17:21:10 CEST 2015


Hi:
I've noticed that if i make a function with for example 3 inputs arguments, and in the call i forget to give one input argument, the function uses (if it exist) a variable from the console with the same name of the missing argument. For example... i have this function:

function y=circconv(x,h,N)
    x=x(:)';h=h(:)';
    hzp=zeros(1,N);xzp=zeros(1,N)
    if length(x)<N then
        xzp=[x zeros(1,N-length(x))]
    else
        xzp=x(1:N);
    end
    if length(h)<N then
        hzp=[h zeros(1,N-length(h))]
    else
        hzp=h(1:N);
    end
    y=ifft(fft(xzp).*fft(hzp))
endfunction

If i call the function without giving the argument N, but there is a variable called N in the workspace, it uses that N...
Is this intentional? So, if i want the user to give exactly the 3 arguments... the only solution would be using argn?

because this was causing me some bugs
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20150410/308f61b4/attachment.htm>


More information about the users mailing list