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

2 次查看(过去 30 天)
like this : 0 1 0 0 0 1

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by