From cdd55940b7a287810e423017c42e7c965815c468 Mon Sep 17 00:00:00 2001 From: Sunil Shetye Date: Wed, 25 Jul 2018 17:32:17 +0530 Subject: code changes by Shashikiran Yadalam during FOSSEE Fellowship 2018 --- macros/wrev.sci | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'macros/wrev.sci') diff --git a/macros/wrev.sci b/macros/wrev.sci index a01ed77..343b24c 100644 --- a/macros/wrev.sci +++ b/macros/wrev.sci @@ -1,12 +1,25 @@ -function [y]= wrev(x) +// Copyright (C) 2018 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Author:[insert name] +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in -// Reverses order of elements of input vector + +function y = wrev(x) + + + // Reverses order of elements of input vector // Calling Sequence // [y]=wrev(x) // Parameters // x: Input vector of string, real or complex values // Description -// This is an Octave function. +// This is an Octave function which is built in scilab. // This function reverses the order of elements of the input vector x. // Examples // 1. wrev([1 2 3]) @@ -15,9 +28,16 @@ function [y]= wrev(x) // ans= cba funcprot(0); -rhs=argn(2); -if (rhs~=1) then - error("Wrong number of input arguments.") -else y=callOctave("wrev",x) + if (argn(2)< 1| argn(2) > 1) then + error("wrong number of input arguments"); //number of input arguments has to be 1 + end + if(~isvector(x))//checks whether input is a vector + error('x must be a vector'); + end + if(type(x)==10 | type(x)==1) then + //revers the vector + l = size(x,"c"); + k = 0:l-1; + y = x(l-k); end endfunction -- cgit