create a vector of 0 and 1s that takes 1 at a fixed interval
조회 수: 1 (최근 30일)
이전 댓글 표시
I would like to create a vector of 0s that takes 1 at a given (m) interval. For example, if m=2, the vector will be like
0,0,1,0,0,1,0,0,1,...
what will be a simpler way to create such vector?
댓글 수: 0
채택된 답변
추가 답변 (2개)
Sulaymon Eshkabilov
2020년 8월 14일
Hi,
O=zeros(1, 20);
m=input('m = ');
IN=m+1:m+1:numel(O);
O(IN)=1;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!