フィルターのクリア

How can I create a vector of numbered names

16 ビュー (過去 30 日間)
Anas Zh
Anas Zh 2021 年 11 月 26 日
編集済み: Peter Perkins 2021 年 11 月 26 日
How can I create a vector of number names
for example,
n=8;
v= ["λ1","λ2".... ,"λn"]
so i can get a vector v= ["λ1","λ2","λ3","λ4","λ5","λ6","λ7","λ8"]
as i want to use it in table .....'RowNames',v)
The n value wanted to be changed so the question again how to number the name based on n
  2 件のコメント
KSSV
KSSV 2021 年 11 月 26 日
I don't think you can use special symbols in table.
Peter Perkins
Peter Perkins 2021 年 11 月 26 日
編集済み: Peter Perkins 2021 年 11 月 26 日
You actually can:
>> v = ["λ1","λ2","λ3"]
v =
1×3 string array
"λ1" "λ2" "λ3"
>> t = table([1;2;3],'RowNames',v)
t =
3×1 table
Var1
____
λ1 1
λ2 2
λ3 3
>> t('λ3',:)
ans =
table
Var1
____
λ3 3
Originally, variable names had to be valid MATLAB identifiers, but now even those can have arbitrary characters. With variable names and dot indexing, you can't write t.λ3, you need to write something like t.('λ3'). But with row names there's no dot indexing, you always have to put row names in quotes like t('RowName',:). So there's not really a reason to limit row names to valid identifiers.

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

採用された回答

Walter Roberson
Walter Roberson 2021 年 11 月 26 日
v = "λ" + (1:n)
  1 件のコメント
Anas Zh
Anas Zh 2021 年 11 月 26 日
thank you

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by