[Scilab-users] SciLab euivalent of Perl's map() function?

Samuel Gougeon sgougeon at free.fr
Sat Apr 8 11:37:44 CEST 2017


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170408/86736c31/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eakmlkkelonhamja.png
Type: image/png
Size: 5700 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20170408/86736c31/attachment.png>


More information about the users mailing list