Extracting Data above a specifc year

1 回表示 (過去 30 日間)
JMG
JMG 2021 年 7 月 15 日
コメント済み: JMG 2021 年 7 月 15 日
Hello I am trying to figure out the best way to keep only the data from the year 1981 and up. I was thinking of doing something like this:
load('dataFC21.mat');
dataFC21.Year=year(dataFC21.Date);
[g,id]=findgroups(dataFC21.Year);
idx=(id>=1981);
dataFC21=dataFC21(idx,:);
Except that this isnt working. If someone could tell me what the issue with my code is or suggest a better method that would be great thanks!

採用された回答

dpb
dpb 2021 年 7 月 15 日
idx isn't the year; it's an index into the array by year.
Simply
yrWant=1981;
dWant=dataFC21(dataFC21.Year>=yrWant,:);
will return those rows presuming that dataFC21.Year is indeed the calendar year and is a double.
  1 件のコメント
JMG
JMG 2021 年 7 月 15 日
Oh perfect thank you for the help!

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by