Use logic index to sort back to original data that are logic 1.
1 view (last 30 days)
Show older comments
Hello community,
I am working sorting out data that has logical value is 0. I am trying to explain what I wanna do clearly and consisely.
I have a original data set in excel that is attached 'test1gofcells.xlsx", the first column is x coorindates and second is y coordinates of each sheet. After some calculation, the data is output as 'IndiMSD', I use the following code to define [100 100000] as lower and upper boundary to include the data (last element of each columns) within and exclude data without.
I already do the logic to identify the sheets that I dont want to include (logic = 0), so I have a row matrix (ix) in logic numbers of 0 and 1. Now I want to use ix to trace back to the sheets in 'test1gofcells' only are logic = 1, and output those sheets.
This is my code to compare 'IndiMSD' to [100 100000] and do the logic:
ix=iswithin(IndiMSD(end,:),100,100000);% get data that are only between 100 and 100000;
% IndiMSD is calculated from original file
IndiMSD_within = IndiMSD(:,ix); %get columns that are only logic = 1;
I don't know how to use ix to get back to the columns within 'test1gofcells' with logic = 1. Please help!
Thank you.
1 Comment
dpb
on 11 Oct 2023
tT=readmatrix('test1gofcells.xlsx');
tI=readmatrix('IndiMSD.xlsx');
whos t*
But "test1gofcells" has only two columns whereas 'IndiMSD" has 116. Something can't be right here or we're not following and don't have enough code to see what transpired from start to finish.
However, presuming you start with more (or as many) columns in "test1gofcells" as you end up with, this is a time where you may need to apply find to the logical vector ix to return the absolute number(s) of the selected columns.
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!