[Scilab-users] basic question ?

paul.carrico at free.fr paul.carrico at free.fr
Sun Apr 23 22:25:17 CEST 2017


Hi All

I'm sorry if my question is "basic", but I've not understood why the
following code does not work ... size of i,j,k seems correct 

Do I miss something? 

Thanks for your time 

Paul

############################## 

mode(0)

n = 10;

A = rand(n,6);
B = zeros((2*n),2); C = B;

// goal is to get the value of the 1rst and 4th column in 2 lines
i = [1 : (2*n)]';
j = [1 : n]'.*.ones(2,1); // gives [1 1 2 2 3 3 .... n n]'
k = ones(n,1).*.[1 4]';  // gives [1 4 1 4 1 4 .... 1 4]'

 tmp = [i j k] // to visualize the indexes

//B(i,1) = A(j,k); // does not work??
C(1,1) = A(1,1);
C(2,1) = A(1,4);
C
A
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170423/13188d00/attachment.htm>


More information about the users mailing list