how can i change a position of a matrix to 1?

4 次查看(过去 30 天)
i have a matrix a=rand(1,10). now i want to change 2,4,6 position of matrix to 1.
how can i do that....
plz plz plz help me

采纳的回答

Matt J
Matt J 2014-6-30

更多回答(1 个)

Andrei Bobrov
Andrei Bobrov 2014-6-30
a = rand(10,1);
a(randperm(10,3)) = 1;

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by