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

1 回表示 (過去 30 日間)
Malak
Malak 2013 年 4 月 14 日
How can I create a vector that alternates 10 and 8 100 times?
  1 件のコメント
Randy Souza
Randy Souza 2013 年 4 月 15 日
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.

サインインしてコメントする。

採用された回答

Iman Ansari
Iman Ansari 2013 年 4 月 14 日
Hi
a=zeros(1,100);
a(1:2:99)=10;
a(2:2:100)=8;
  1 件のコメント
Malak
Malak 2013 年 4 月 14 日
how can we do it in one command ?

サインインしてコメントする。

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2013 年 4 月 15 日
repmat([10 8],1,100)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by