How can I write a matrix 6x1 that the element (2,1) and (6,1) equal to 1 and others are zero?

2 Ansichten (letzte 30 Tage)
like this : 0 1 0 0 0 1

Akzeptierte Antwort

Star Strider
Star Strider am 8 Okt. 2014
If the vector is ‘A’, this works:
A([2 6]) = 1;
produces:
A =
0 1 0 0 0 1

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by