[Scilab-users] SciLab euivalent of Perl's map() function? (scilab: message 8 of 20)

scilab.20.browseruk at xoxy.net scilab.20.browseruk at xoxy.net
Sat Apr 8 13:17:33 CEST 2017


Easy!? When you know how.

Thanks Samuel.

> -----Original Message-----
> From: scilab.browseruk.bb30c473ec.sgougeon#free.fr at ob.0sg.net
> Sent: Sat, 8 Apr 2017 11:37:44 +0200
> To: users at lists.scilab.org
> Subject: Re: [Scilab-users] SciLab euivalent of Perl's map() function?
> (scilab: message 8 of 20)
> 
> Hello,
> 
> Le 08/04/2017 à 04:47, scilab.20.browseruk at xoxy.net a écrit :
>> Hi,
>> 
>> I want to do the equivalent of
>> 
>>      plot( xdata, xdata .^ 2, xdata .^ 3, xdata '^ 4, ... );
>> 
>> and benefit from the plot() color rotation, without having to repeat the
>> equation.
>> 
>> In Perl I might do (something like):
>> 
>>      plot( xdata, map xdata .^ $_, 2 .. 5 );
>> 
>> Something like that in SciLab?
> 
> x = -2:0.1:2;
> pw = [1 2 3 4];
> [X,P] = ndgrid(x, pw);
> clf
> plot(x, X.^P)
> 
> xtitle("Power laws","x")
> legend(msprintf("$x^%d$\n",pw'),4)
> 
> HTH
> Samuel






More information about the users mailing list