Hello,

Le 25/04/2017 à 15:29, SCHULZ Wolfgang a écrit :
Hello,
I want to set certain elements of a matrix to 1. Interestingly the following 
code fills 9 elements with 1. I expected to have only 3 elements (with index 
1,1; 2,2 and 3,3) filled with 1.

A=zeros(5,3)
inx=[1 2 3];
iny=[1 2 3];
A(inx,iny)=1


Using this is for submatrix but what you want is not a submatrix. In your special case A=eyes(5,3)


Is there any way to fill a matrix with 1 where I have the indexes in 2 vectors?


IMHO only the for loop works, in general...

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

Reply via email to