cellCount - %always be a new cell element vec = ; %creates...

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
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %always be a new cell element 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 ca([vec]) = ; end...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Institute of Technology.

Ask a homework question - tutors are online