MATLAB: How to write a matrix 6×1 that the element (2,1) and (6,1) equal to 1 and others are zero

matrixprogramming of matrix

like this : 0 1 0 0 0 1

Best Answer

If the vector is ‘A’, this works:
A([2 6]) = 1;
produces:
A =
0 1 0 0 0 1
Related Question