フィルターのクリア

getting info from a unique ID in a csv

3 ビュー (過去 30 日間)
Jorge Young
Jorge Young 2020 年 12 月 4 日
コメント済み: dpb 2020 年 12 月 4 日
Thank you in advance for help on this.
I am fairly new to matlab, and I am trying to figure out how to find values in a .csv relating to each individual ID. For example, how can I find the time that each elevator ID reaches the 2nd floor for the first time?

採用された回答

dpb
dpb 2020 年 12 月 4 日
編集済み: dpb 2020 年 12 月 4 日
Power of the MATLAB table comes fore...
tElev=readtable('elevatorexample.csv');
FindFloor=2; % the floor to find
rowfun(@(f,t) t(find(f==FindFloor,1)),tElev,'InputVariables',{'floor','time'}, ...
'GroupingVariables','elevatorID', ...
'OutputVariableNames',"FirstTimeToFloor "+FindFloor)
ans =
6×3 table
elevatorID GroupCount FirstTimeToFloor 2
__________ __________ __________________
1 6 2
2 5 2
3 5 1
4 5 2
5 4 1
6 4 1
>>
  2 件のコメント
Jorge Young
Jorge Young 2020 年 12 月 4 日
This is fantastic, thank you very much!
dpb
dpb 2020 年 12 月 4 日
Yeah, read up on grouping variables and the rowfun, varfun functions. There's whole section on splitapply for more discussion as well.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by