How to create a vector consisting of repeating 1's and 0's.

조회 수: 7 (최근 30일)
Nicholas Wolf
Nicholas Wolf 2021년 7월 6일
답변: KSSV 2021년 7월 6일
I need to create a column vector consisting of alternating 1's and 0's [1 0 1 0 1 0 1 0 ... 0 1] for n times. Could anyone help assist with this?

답변 (1개)

KSSV
KSSV 2021년 7월 6일
A = [1 0] ;
n = 10 ;
iwant = repmat(A,1,n)
iwant = 1×20
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by