Extract values from a data table and create a new table

1 回表示 (過去 30 日間)
Nuria Andreu
Nuria Andreu 2022 年 7 月 6 日
コメント済み: Nuria Andreu 2022 年 7 月 9 日
Hello! I have a data file with multiple data points including date and precipitation values (range from 0.1 inches to 2 inches).
I want to extract all of the precipitation values over 1 inch and store them in a new table with its proper date. Anyone has some tips or ideas on how to do this? I gave up after multiple tries.
Thank you in advance!
  2 件のコメント
Chunru
Chunru 2022 年 7 月 7 日
upload a sample data in readable format such as .mat or .csv
Nuria Andreu
Nuria Andreu 2022 年 7 月 7 日
Data = readtable('Sta_Teresa.csv');
%like this?

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

採用された回答

Chunru
Chunru 2022 年 7 月 7 日
T = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1057240/Sta_Teresa.csv");
T1 = T(T.PRCP > 1, :)
T1 = 94×4 table
STATION NAME DATE PRCP _______________ _______________________________ __________ ____ {'USC00298127'} {'SANTA TERESA AIRPORT, NM US'} 07/16/0002 1.11 {'USC00298127'} {'SANTA TERESA AIRPORT, NM US'} 07/19/0002 1.04 {'USC00298127'} {'SANTA TERESA AIRPORT, NM US'} 06/27/0004 1.06 {'US1NMDA0092'} {'SANTA TERESA 0.5 SSW, NM US'} 07/28/0006 1.55 {'USC00298127'} {'SANTA TERESA AIRPORT, NM US'} 07/31/0006 1.91 {'USC00298127'} {'SANTA TERESA AIRPORT, NM US'} 08/01/0006 2.03 {'US1NMDA0092'} {'SANTA TERESA 0.5 SSW, NM US'} 08/01/0006 3.06 {'US1NMDA0092'} {'SANTA TERESA 0.5 SSW, NM US'} 08/02/0006 1.15 {'USC00298127'} {'SANTA TERESA AIRPORT, NM US'} 08/16/0006 1.14 {'US1NMDA0092'} {'SANTA TERESA 0.5 SSW, NM US'} 08/19/0006 1.89 {'USC00298127'} {'SANTA TERESA AIRPORT, NM US'} 09/03/0006 1.45 {'US1NMDA0092'} {'SANTA TERESA 0.5 SSW, NM US'} 09/03/0006 1.02 {'USC00298127'} {'SANTA TERESA AIRPORT, NM US'} 09/04/0006 1.16 {'US1NMDA0092'} {'SANTA TERESA 0.5 SSW, NM US'} 09/04/0006 1.28 {'US1NMDA0159'} {'SANTA TERESA 1.0 WNW, NM US'} 08/01/0007 1.38 {'US1NMDA0092'} {'SANTA TERESA 0.5 SSW, NM US'} 08/02/0007 1.56
  1 件のコメント
Nuria Andreu
Nuria Andreu 2022 年 7 月 9 日
Thank you ! this is what I was looking for

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

その他の回答 (1 件)

dpb
dpb 2022 年 7 月 7 日
What did you try? Have you looked at the "Getting Started" section on array indexing/addressing; specifically logical indexing?
PLevel=1; % the magic constant -- don't bury in code, use variables
tPrecipGreater=tPrecip(tPrecip.PRCP>Plevel,:);
That's it...
  1 件のコメント
Nuria Andreu
Nuria Andreu 2022 年 7 月 9 日
Thank you! this one also works perfectly!

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

カテゴリ

Help Center および File ExchangeWeather and Atmospheric Science についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by