Is there a command to index months in a timetable series?
I would like to index one long term timetable in two ways. In one, all July, August, and September are indexed. In the second Novemeber through March are indexed.
My timetable is a daily series.

 採用された回答

Adam Danz
Adam Danz 2020 年 9 月 23 日
編集済み: Adam Danz 2020 年 9 月 23 日

0 投票

Logical index of rows that are in July,Aug,Sept.
idx = ismember(month(TT2_staLCA_WS.Time),[7,8,9]);

4 件のコメント

Eric Escoto
Eric Escoto 2020 年 9 月 23 日
編集済み: Eric Escoto 2020 年 9 月 23 日
Nice. So this provides the logical array. What is the next step to pull those values (meaning the data and Time columns) into a new TT? Is it an 'if' statement?
Adam Danz
Adam Danz 2020 年 9 月 23 日
It's just basic indexing.
For example,
T = table((1:5)',["A";"B";"C";"D";"E"])
% T =
% 5×2 table
% Var1 Var2
% ____ ____
% 1 "A"
% 2 "B"
% 3 "C"
% 4 "D"
% 5 "E"
idx = ismember(T.Var1, [1,3,4]) % rows where var1 is 1,3,or 4
% idx =
% 5×1 logical array
% 1
% 0
% 1
% 1
% 0
% EXAMPLES OF INDEXING
T(idx,:)
% 3×2 table
% Var1 Var2
% ____ ____
% 1 "A"
% 3 "C"
% 4 "D"
T.Var2(idx)
% 3×1 string array
% "A"
% "C"
% "D"
Eric Escoto
Eric Escoto 2020 年 9 月 23 日
Ah of course. Perfect.
Thanks, Adam!
Adam Danz
Adam Danz 2020 年 9 月 23 日
Socially distant high-five!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

質問済み:

2020 年 9 月 23 日

コメント済み:

2020 年 9 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by