Data sorting using logic
Show older comments
Hello everyone, I am using R2023a to do data sorting using logic to remove some data, save and output the other part of the data. The original data is attached, called 'IndiMSD', with a size of 97 by 107. I want to first examine the last element of each column to see if they are below 5000 or exceed 60000, it they are, they will be excluded; it not, they will be included to be saved and used for furthur use.
Here are my codes for now,
I think I can examine the last element of each column to see if they are within the range, and do a logic calculation. For this data set, my code can cut down from 107 to 95 after the doing the logic. But when I try to sort out the data for the columns with a logical value 1, I am having some trouble. The sorted out data gives a 95 by 97 matrix but starting from the first column without identifying 'logic = 0' columns. Can someone help me on this to let it only output the columns that are logic 1, not from the beginning?
Thank you.
goodRows1 = logical(iswithin(IndiMSD(97,:),5000,60000));% examine last element of each column
logic_MSDwithin = goodRows1(:,goodRows1); % compare to the range
IndiMSD_within4 = IndiMSD(:, logic_MSDwithin);% output data that are logical value is 1
Accepted Answer
More Answers (0)
Categories
Find more on Shifting and Sorting Matrices 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!