Good afternoon Matlab forums!
I've been working on a code to sort an array of data that includes both numbers and string values. Basically, within column 1 I have identification #'s, in column 2, I have strings, and in column 3 I have charges to be summed.
I am attempting to extract a histogram which shows the occurrences of the strings in column 2 based on particular conditions of the set. Basically, for each unique column 1 ID#(There are multiple occurences of the same here), I wish to check if Column 3 adds up to a particular threshold, in this case being 10,000. Here is a sample of my current code.
Q = cellfun(@str2num,SUB_ID,'UniformOutput',false);D = cell2mat(Q);concentated = [D C];unique_ids = unique(concentated(:,1));n_ids = length(unique_ids);for i = 1:n_ids; A_id = concentated(concentated(:,1) == unique_ids(i),:); sum_id = sum(A_id(:,2)); if sum_id >= 10000 disp(unique_ids(i)) disp(sum_id) endend
The beginning of this code is me creating a 2 column matrix with the data in the array, excluding the previous "Column 2" data, as I can't seem to figure out how to make these loops work within in array as opposed to a matrix. Any help would be appreciated!!!
Thanks, J
Best Answer