[Scilab-users] Problem with Matrix operation

SCHULZ Wolfgang W.Schulz at ove.at
Tue Apr 25 15:29:35 CEST 2017


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

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

Thanks for your help
Wolfgang



More information about the users mailing list