How to cut a matrix?

조회 수: 5 (최근 30일)
Daniel Tanner
Daniel Tanner 2020년 5월 15일
댓글: Ameer Hamza 2020년 5월 15일
I have a matrix that is 35000-by-11. The first column specifies a depth and the next ten specify data at that certain depth. I am only interested in data between the depths of 241 and 285. How do I identify which elements in the column are in those regions and essentially create a new matrix with just the region of interest? Sorry if this is simple as I am still new to MatLab!
Thanks!

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 15일
편집: Ameer Hamza 2020년 5월 15일
Something like this
M % matrix of dimensions 35000-by-11
depths = M(:,1);
idx = (241 < depths) & (depths < 285)
M_new = M(idx, :)
M_new is the required matrix in which the element in the first column is only in range (241, 285).
  댓글 수: 2
Daniel Tanner
Daniel Tanner 2020년 5월 15일
Thank you Ameer!
Ameer Hamza
Ameer Hamza 2020년 5월 15일
I am glad to be of help.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by