How can I extract a specific row from a table?

6 ビュー (過去 30 日間)
Ashfaq Ahmed
Ashfaq Ahmed 2023 年 2 月 6 日
コメント済み: Voss 2023 年 2 月 6 日
Hi all!
Suppose I have a table with two column (i.e., Date and Temperature) like this -
Please note that every date has multiple temperature assign to it. Now, I have another array that has three dates -
How can I extract these three days from the previous table with all the associated temperature? I mean, I want a matrix that will have these three dates with all the temperatures. Thus, 9 columns.
I have attached the DateToFind.mat file in this question. Can any one please help?

採用された回答

Voss
Voss 2023 年 2 月 6 日
編集済み: Voss 2023 年 2 月 6 日
load DateToFind
result = T(ismember(T.Date,Date_to_find),:)
result = 9×2 table
Date Temperature ____________ ___________ {'1/1/2021'} 1 {'1/1/2021'} 2 {'1/1/2021'} 3 {'4/1/2021'} 10 {'4/1/2021'} 11 {'4/1/2021'} 12 {'5/1/2021'} 13 {'5/1/2021'} 14 {'5/1/2021'} 15
Then, if you want those temperatures in a matrix with 9 columns:
result = result.Temperature.'
result = 1×9
1 2 3 10 11 12 13 14 15
  2 件のコメント
Ashfaq Ahmed
Ashfaq Ahmed 2023 年 2 月 6 日
Hi @Voss ! Yes, that helps! Thanks a ton.
Voss
Voss 2023 年 2 月 6 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by