Azzera filtri
Azzera filtri

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

4 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

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

Accedi per commentare.

Più risposte (1)

Andrei Bobrov
Andrei Bobrov il 30 Giu 2014
a = rand(10,1);
a(randperm(10,3)) = 1;

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by