フィルターのクリア

How do I extract certain data from a table?

66 ビュー (過去 30 日間)
Philipp Henschel
Philipp Henschel 2017 年 11 月 10 日
編集済み: Walter Roberson 2020 年 7 月 15 日
I'm working on a tall array, which contains multiple flightplan data (size over 100k rows, 5 columns) and I want to extract just certain flight routes (departureairport --> arrivalairport) and continue to work with them.
The table looks approximately like this:
flightno. depart.airp arr.airp depart.time arr.time
--------- ----------- -------- ----------- --------
111 BOS LAX ... ...
321 JFK DEN ...
121 BOS JFK
222 DEN BOS
333 BOS DEN
For the further data analysis I only want to work with flight data departuring from BOS.
Could someone help me on this issue? Thanks
  2 件のコメント
Birdman
Birdman 2017 年 11 月 10 日
Can you send the tall array(data)?
Philipp Henschel
Philipp Henschel 2017 年 11 月 10 日
Not sure if I can share the file. Instead I posted you a few rows out of the tall array
flighthistoryid departureairport arrivalairport originaldepartureutc originalarrivalutc
_______________ ________________ ______________ ____________________ ___________________
2.803e+08 'PDX' 'LAS' 2012-11-14 02:55:00 2012-11-14 05:00:00
2.8031e+08 'RDM' 'SEA' 2012-11-14 02:55:00 2012-11-14 04:02:00
2.803e+08 'PUW' 'SEA' 2012-11-14 02:55:00 2012-11-14 04:05:00
2.8029e+08 'MFR' 'PDX' 2012-11-14 02:55:00 2012-11-14 03:56:00
2.8031e+08 'SLC' 'TWF' 2012-11-14 02:55:00 2012-11-14 03:59:00
2.8028e+08 'HOU' 'DFW' 2012-11-14 02:55:00 2012-11-14 04:00:00
2.8025e+08 'ATL' 'BOS' 2012-11-14 02:51:00 2012-11-14 05:25:00
2.8025e+08 'ATL' 'STL' 2012-11-14 02:53:00 2012-11-14 04:45:00

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

採用された回答

dpb
dpb 2017 年 11 月 10 日
I'd guess the ID column isn't a float but an integer number; need to ensure you've imported it with sufficient precision to be correct.
Then convert flight airport IDs to categorical arrays...
T(:,1:3)=categorical(T(:,1:3)); % where T is your table variable
That will make selection simple to write--
B=T(T.departure=='BOS',:);
You can write similar things with cell strings, but in general the syntax is more messy and the categorical variable type has some useful builtin utility functions for summaries and the like that can be helpful.
  8 件のコメント
dpb
dpb 2020 年 7 月 15 日
Huh. Surprised nobody else had noticed..."air code" (meaning just typed in at the prompt, not tested) tends to have such oversights. The expression needs the curlies ("{}") instead of parentheses to return the base array when using subscript indexing into a table.
T.name for a column variable does return the variable as its storage type; it's easy to forget that the array indexing form returns the table section referred to instead. It's consistent wit MATLAB syntax; just easy to forget/overlook.
Walter Roberson
Walter Roberson 2020 年 7 月 15 日
編集済み: Walter Roberson 2020 年 7 月 15 日
data = cat(1, image_patches,labels);
That code is overwriting all of data each iteration.
It looks to me as if data will not be a vector, but I do not seem to be able to locate any hellopatches() function so I cannot tell what shape it will be. As you are not doing imresize() I also cannot be sure that all of the images are the same size, so I cannot be sure that data will be the same size for each iteration. Under the circumstances you should be considering saving into a cell array.
Note: please do not post the same query multiple times. I found at least 10 copies of your query :(

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by