cellCount - vec = ; %creates an empty vector to concatenate...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function st = cellCount(ca) %function to count the number of times each string occurs in the cell %array; the output will be a structure where each unique string from the %cell array is a field, and each field will contain a double indicating how %many times the string appeared in the cell array %usage: st = cellCount(ca) st = []; %creates an empty vector to concatenate later while length(ca) > 0 %creates a while loop that only runs while the length of ca actually %exists y = ca{1}; %because the dimensions of the ca will change, the 1st position will %always be a new cell element
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: vec = ; %creates an empty vector to concatenate later for z = 1:length(ca) if strcmp(y,ca{z}) %if the string pulled out of ca is the same as element in each %position of ca, then the loop will continue vec = [vec z]; %concatenates the new vector end end st.(y) = length(vec); %the new fieldname will be the string in the variable y, and it will %equal the length of the positions where y was true when run through %the if conditional ca([vec]) = ; %this will remove the positions of the elements equal to the y string %value end end...
View Full Document

Ask a homework question - tutors are online