Extract row data from a table as a result of intervals (boundaries) being called in from a different structure
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jake Bowd
am 15 Jun. 2020
Beantwortet: Sindar
am 16 Jun. 2020
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 Kommentare
Sindar
am 15 Jun. 2020
Are INITIAL and END indexes or values?
How do you choose which rows to extract if comparing all elements of DATA?
Regardless, read this tutorial: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html
Akzeptierte Antwort
Sindar
am 16 Jun. 2020
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!