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 CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by