How to Give Column Names to MATLAB Table Dynamically

66 ビュー (過去 30 日間)
Gazi Alam
Gazi Alam 2019 年 6 月 19 日
編集済み: Walter Roberson 2019 年 6 月 19 日
Hi all, I am having trouble to assign colum name of a mtlab table.
I want to make a table of 365 rows and suppose 29 columns. I want to assign the column names from the years from the vector
T=[1990, 1992, ... 2018]
I know how to do it like this:
colnames = {'a' 'b'};
a = [1;2];
b = [3;4];
c = table(a, b, 'VariableNames', colnames)
If I want to make 'colnames' from my T vector, how can I do it?

採用された回答

Walter Roberson
Walter Roberson 2019 年 6 月 19 日
Column names must be valid matlab variable names.
colnames = "AD" + T;
The AD can be changed to any valid prefix of a variable name.
As written this code requires R2017a or later
  1 件のコメント
Gazi Alam
Gazi Alam 2019 年 6 月 19 日
Thanks Walter Roberson. It works.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by