What kind of join will work to merge these two tables

1 回表示 (過去 30 日間)
alpedhuez
alpedhuez 2020 年 12 月 12 日
回答済み: Jeff Miller 2020 年 12 月 13 日
I have table T1
date city vistors
---------------------
January 1 2020 NY 100
January 2 2020 NY 200
January 1 2020 SF 150
January 4 2020 SF 50
I have table T2
city state
----------
NY New York
SF Calfiornia
I want Matlab to create T3
date city vistors state
---------------------
January 1 2020 NY 100 New York
January 2 2020 NY 200 New York
January 1 2020 SF 150 California
January 4 2020 SF 50 California
  2 件のコメント
Image Analyst
Image Analyst 2020 年 12 月 12 日
Make it easy for us to help you, not hard. Give us code to create the input tables T1 and T2.
What happens if you just simply try the various flavors of join? Maybe you'll stumble across the right one.
One non-join way is to simply use a for loop and ismember().
alpedhuez
alpedhuez 2020 年 12 月 12 日
Let me work on it.

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

採用された回答

Jeff Miller
Jeff Miller 2020 年 12 月 13 日
Try
T3 = join(T1,T2,'Keys','City')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by