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

1 Ansicht (letzte 30 Tage)
suchismita
suchismita am 30 Jun. 2014
Kommentiert: suchismita am 30 Jun. 2014
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

Akzeptierte Antwort

Matt J
Matt J am 30 Jun. 2014
a([2,4,6])=1
  1 Kommentar
suchismita
suchismita am 30 Jun. 2014
thank u....if the positions are random then what will be the code????

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Andrei Bobrov
Andrei Bobrov am 30 Jun. 2014
a = rand(10,1);
a(randperm(10,3)) = 1;

Kategorien

Mehr zu Creating and Concatenating Matrices 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