Enter same string in an array.

36 ビュー (過去 30 日間)
Akashdeep Kaur
Akashdeep Kaur 2022 年 7 月 16 日
コメント済み: Akashdeep Kaur 2022 年 7 月 16 日
hello, I would like to enter same string in an array. like:
Array1=[a,a,a,a,a,a]
Thanks.

採用された回答

Harshit Gupta
Harshit Gupta 2022 年 7 月 16 日
Hi, if your question is just about how to create an array of string, you can do it like this:
Array1 = ["a", "a", "a", "a", "a"]
Array1 = 1×5 string array
"a" "a" "a" "a" "a"
Now if you want to repeat a single string multiple times to create an array, do it like this:
str = "a";
Array1 = repmat(str, 1, 5)
Array1 = 1×5 string array
"a" "a" "a" "a" "a"
Refer to the documentation to know more: repmat
Hope this helps!
  1 件のコメント
Akashdeep Kaur
Akashdeep Kaur 2022 年 7 月 16 日
Thank you for helping.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by