just replace

fori = 1 : nl

C(i,1) = A(i,1)*B(i,1);

end

by

C(:,1) = A(:,1) .*B(:,1);

Serge Steer

On 15/11/2012 09:21, Paul Carrico wrote:

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);

fori = 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
[email protected]
http://lists.scilab.org/mailman/listinfo/users

_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users

Reply via email to