Sorting data in large data set

8 ビュー (過去 30 日間)
Alex Herron
Alex Herron 2019 年 6 月 11 日
編集済み: Adam Danz 2020 年 1 月 15 日
example_of_data.PNG
I'm working with a large (78024x7 cell array) data set and I'm trying to trim it down a bit. The first column is depth and the seventh column is month (numerical). One way to shave down this data is by getting rid of all the March, April, May, September, October, & November values (3,4,5,9,10,11), as I do not need these values. Furthermore, any data point below the depth of 400 is useless to me.
I'm looking to eliminate all the rows that fit this criteria in order to make this data set easier to work with, but I'm having trouble getting started. Any tips?

採用された回答

Adam Danz
Adam Danz 2019 年 6 月 11 日
編集済み: Adam Danz 2019 年 6 月 12 日
The data in the image you shared appear to be in a spreadsheet and surrounded by single quotes. I'll assume you've imported those data into matlab. You menionted your data is stored in a cell array. If your cell array contain strings (due to the single quotes) you can convert those data to a matrix by using str2double(). If the cell array contains numeric data, you can convert that to a matrix using cell2mat().
m = str2double(data);
m = cell2mat(data);
Once you have a matrix, you can eliminate rows of data like this
badMonths = [3,4,5,9,10,11];
depthMax = 400;
m(ismember(m(:,7),badMonths),:) = []; %get rid of rows with bad months
m(m(:,1)>depthMax,:) = []; %get rid of rows with depths > 400
*Update: Corrected one character in the block above (explained below in comments).
  5 件のコメント
Adam Danz
Adam Danz 2019 年 6 月 12 日
編集済み: Adam Danz 2020 年 1 月 15 日
Glad I could help!
Alex Herron
Alex Herron 2019 年 6 月 12 日
you got it

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by