How do I create this vector: [10,8,10,8,10, ...]?

1 vue (au cours des 30 derniers jours)
Malak
Malak le 14 Avr 2013
How can I create a vector that alternates 10 and 8 100 times?
  1 commentaire
Randy Souza
Randy Souza le 15 Avr 2013
I have restored the original text of this question.
@Malak: this question has a clear subject and an accepted answer, so it may be valuable to someone else in the future. If you have a good reason why it should be removed from MATLAB Answers, please flag the question, explain why it should be deleted, and an administrator or high-reputation contributor will consider deleting the question. Please do not simply edit your question away.

Connectez-vous pour commenter.

Réponse acceptée

Iman Ansari
Iman Ansari le 14 Avr 2013
Hi
a=zeros(1,100);
a(1:2:99)=10;
a(2:2:100)=8;
  1 commentaire
Malak
Malak le 14 Avr 2013
how can we do it in one command ?

Connectez-vous pour commenter.

Plus de réponses (1)

Andrei Bobrov
Andrei Bobrov le 15 Avr 2013
repmat([10 8],1,100)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by