フィルターのクリア

create a table with strings and numbers

315 ビュー (過去 30 日間)
Giannis Nikolopoulos
Giannis Nikolopoulos 2021 年 5 月 19 日
回答済み: Giannis Nikolopoulos 2021 年 5 月 24 日
Hello,
I have two matrixs let say
a = [1:10] -->Var_1
b = [2:2:20] --> Var_2
and one string matrix:
city = {'city_1', 'city_2','city_3','city_4','city_5','city_6','city_7','city_8','city_9','city_10'}
and I want to create and display the table like the figure:
Could someone help me with this task?
Thanks in advance,
  1 件のコメント
dpb
dpb 2021 年 5 月 19 日
See the doc and examples for the table function --
tData=table(city,a,b,'variablenames',{'City','VarA','VarB'});

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

採用された回答

Chandra Amma Palanisamy
Chandra Amma Palanisamy 2021 年 5 月 20 日
Hi Giannis,
It is my understanding that you want to create a table which consists of string and double in columns. You can use table function which can accept array with named variables that can contain different data types. The example code is given below:
a = (1:10)';
b = (2:2:20)';
city = {'city_1';'city_2';'city_3';'city_4';'city_5';'city_6';'city_7';'city_8';'city_9';'city_10'};
myTable = table(city,a,b,'VariableNames',{'City','Var_1','Var_2'})
Hope this helps.

その他の回答 (1 件)

Giannis Nikolopoulos
Giannis Nikolopoulos 2021 年 5 月 24 日
Thank you for your replies. They helped me a lot!!

カテゴリ

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