Filter löschen
Filter löschen

creating binary vector with determed number of ones

2 Ansichten (letzte 30 Tage)
loukil sana
loukil sana am 24 Apr. 2019
Kommentiert: loukil sana am 24 Apr. 2019
Hello,
i have a vector V= 50; i want to full this vector randomly with 0 and 1. the '1' appears 10 times and the rest of the vector with zeros. how can i do that please

Akzeptierte Antwort

John D'Errico
John D'Errico am 24 Apr. 2019
Bearbeitet: John D'Errico am 24 Apr. 2019
nones = 10;
nv = 50;
V = zeros(1,nv);
V(randperm(nv,nones)) = 1;
  3 Kommentare
John D'Errico
John D'Errico am 24 Apr. 2019
I'm sorry. I cannot/will not keep on chasing totally new questions in the comments. That turns one question into an extended personal consulting session. If you have another question, then ask it. AS ANOTHER QUESTION.
loukil sana
loukil sana am 24 Apr. 2019
ok no problem thank you. i will post it as a new question

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

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