MATLAB Answers

I'm trying to select a value from one column in a cell array based on another value.

1 view (last 30 days)
benjamin powers
benjamin powers on 16 Oct 2018
Answered: OCDER on 16 Oct 2018
I imported an excel table in to matlab as a cell array and want. I have two columns three columns of interest; System ID, Sampling Frequency, and DOH Priority. I want to identify and System ID's that have a DOH priority of 'ND'. From here I want to make another cell array or table with all the System ID's and Sampling frequencies. I've had some success using strfind but it's just giving me my original table with 1's and 0's for the sites. Am I approaching this the right way or is there a better way to do this? Thanks!

Accepted Answer

OCDER
OCDER on 16 Oct 2018
Table = {1 23 'ND';
2 33 'ND';
3 14 'AA';
4 11 'AA';
6 16 'ND'}; %Your table, SystemID (col-1), Frequency (col-2), DOH (col-3);
NDLoc = strcmpi(Table(:, 3), 'ND'); %Logical index of ND columns
NDTable = Table(NDLoc, 1:2); %SystemID and Frequency of ND priority only

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by