[Scilab-users] basic question

Arvid Rosén arvid at softube.com
Thu Nov 15 09:25:21 CET 2012


Hi,

Replace loop with:
C = A.*B;

Arvid

15 nov 2012 kl. 09:21 skrev Paul Carrico <paul.carrico at free.fr>:

> Dear all,
>  
> Sorry for this basic question but I failed in finding the answer after a look in the documentation …
> … how can I optimize the following basic code (using vectorization instead of loops) ?
>  
> Thanks to the community
>  
> Paul
> mode(0)
>  
> A = [1 : 0.2 : 100]'
> B = [100 : 1 : 595]'
>  
> [nl,nc] = size(A);
> C = zeros(nl,1);
>  
> for i = 1 : nl
>     C(i,1) = A(i,1)*B(i,1);
> end
>  
> // D = prod(
> //A(nl,1)*B(nl,1) - C(nl,1)
>  
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

--
Arvid Rosén

Softube AB
S:t Larsgatan 10c
SE-582 24 Linköping
Sweden
Mobile: (+46) 73 25 123 47
Office: (+46) 13 21 16 23
Fax: (+46) 13 10 00 23
Mail: arvid at softube.com
URL: www.softube.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20121115/19c99fd5/attachment.htm>


More information about the users mailing list