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

5 vues (au cours des 30 derniers jours)
Nicholas Wolf
Nicholas Wolf le 6 Juil 2021
Réponse apportée : KSSV le 6 Juil 2021
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?

Réponses (1)

KSSV
KSSV le 6 Juil 2021
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

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by