필터 지우기
필터 지우기

creating binary vector with determed number of ones

조회 수: 1 (최근 30일)
loukil sana
loukil sana 2019년 4월 24일
댓글: loukil sana 2019년 4월 24일
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

채택된 답변

John D'Errico
John D'Errico 2019년 4월 24일
편집: John D'Errico 2019년 4월 24일
nones = 10;
nv = 50;
V = zeros(1,nv);
V(randperm(nv,nones)) = 1;
  댓글 수: 3
John D'Errico
John D'Errico 2019년 4월 24일
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 2019년 4월 24일
ok no problem thank you. i will post it as a new question

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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