Deleting rows that do not contain the state code i want.
2 ビュー (過去 30 日間)
古いコメントを表示
I have attached an excel with 3 columns aid, date, and mean. Each aid is code for a US state.
I want to cut out all rows that do not contain the following aid's
aid0045
aid0024
aid0046
aid0019
aid0038
aid0031
aid0041
aid0013
aid0042
aid0043
aid0030
0 件のコメント
採用された回答
Leulaye Maskal
2021 年 11 月 18 日
1 件のコメント
Image Analyst
2021 年 11 月 18 日
Yes you can. Just alter keeperStrings to be whatever you want. Since it worked, can you click the "Accept this Answer" on my Answer (not yours)? Thanks in advance.
その他の回答 (1 件)
Image Analyst
2021 年 11 月 17 日
Try this:
% Read data into a table.
t = readtable('NPP_STATES_YRLY_MEAN.xls')
% Define "aid" strings that we want to keep/extract.
keeperStrings = {...
'aid0045'
'aid0024'
'aid0046'
'aid0019'
'aid0038'
'aid0031'
'aid0041'
'aid0013'
'aid0042'
'aid0043'
'aid0030'}
% Find out the rows where the keeper strings live.
rowsToKeep = ismember(t.aid, keeperStrings)
% Extract only those specific rows.
t2 = t(rowsToKeep, :)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!