Dear All

Most of the time I've no issue in mixing functions and vectorization, but here 
I don't know why it does not work - one can see that using a vector I, the loop 
is called only ounce and I do not understand why?

I've spent hours in such case  showing I'm not fully at ease with it :-) :-)

Any explanation?

Thanks for your support

Paul

#####################################################################
mode(0)
clear

function [Scar_P]=Scalar_product(C, N, M) // Scalar product
    Scar_P = (M(1) - C(1))*(N(1) - C(1)) + (M(2) - C(2))*(N(2) - C(2));
    printf("C = (%g,%g)\n",C(1),C(2)); printf("N = (%g,%g)\n",N(1),N(2)); 
printf("M = (%g,%g)\n",M(1),M(2));
endfunction

n = 10;

C = rand(n,2);
M = rand(n,2);
N = rand(n,5);

Scal = zeros(n); Scal2 = Scal

printf(" ****************\n");
i = 1 : n;
Scal(i) = Scalar_product(C(i,:),N(i,1:2)',M(i,:))

printf("\n ****************\n");

for i = 1 : n
    Scal2(i) = Scalar_product(C(i,:),N(i,1:2)',M(i,:));
end

EXPORT CONTROL :
Cet email ne contient pas de données techniques
This email does not contain technical data

_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

Reply via email to