Extract row data from a table as a result of intervals (boundaries) being called in from a different structure

조회 수: 1 (최근 30일)
Hi There,
I have a 328x338 double matrix (name: DATA), a variable (name: INITIAL) and another variable (name: END).
I wish to extract all the data in DATA that falls with the boundaries INITIAL and END.
Could someone point me in the right direction to get this?
Best wishes,
Jake
  댓글 수: 2
Sindar
Sindar 2020년 6월 15일
Are INITIAL and END indexes or values?
How do you choose which rows to extract if comparing all elements of DATA?
Jake Bowd
Jake Bowd 2020년 6월 15일
Hi Sindar,
Thank you so much for your reply.
INITIAL and END are values stored seperately to the DATA matrix. I want to use the first column in the DATA matrix to determine what is extracted when using the INITIAL and END values.
If it helps to visualise I can attached the actual data?
Many thanks for the link I can't see which part I'm concerned with yet :).
Best wishes,

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

채택된 답변

Sindar
Sindar 2020년 6월 16일
Does this do it?
% generate some random data 0-1
DATA = rand(328,338);
% set the lower and upper bounds to extract as 0.25 and 0.75
INITIAL = 0.25;
END = 0.75;
% identify indexes of the first column in this range
idx = (DATA(:,1) >= INITIAL) & (DATA(:,1) <= END);
% extract corresponding rows using logical indexing
newDATA = DATA(:,idx);
merging the idx line:
% extract rows based on the first column in this range
newDATA = DATA(:,(DATA(:,1) >= INITIAL) & (DATA(:,1) <= END));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by