f = fopen('pizzasize.txt','r');     %read the same data from txt file

pmans={'Dominos', 'EagleBoys'}; %manufacturers of pizza; 
                                %this is a cell array

%% read lines from a text file untile reaching the end of file                                
dsizes=[];
esizes=[];
l = fgetl(f);   %get a line from file
while ischar(l) %untile the end of file
    if ~isempty(strfind(l, pmans{1}))
        tabpos = find(l==9);        %ascii value of TAB  = 9
        sz = str2num(l(tabpos(end)+1:end));  %the sub-string after the last TAB is size data
        dsizes = [dsizes; sz];      %append the size data to the array; resize array every time: inefficient
    elseif ~isempty(strfind(l, pmans{2}))
        tabpos = find(l==9);   
        sz = str2num(l(tabpos(end)+1:end));
        esizes = [esizes; sz];
    end
    l = fgetl(f);   %get next line, non-char is reached the end
end
fclose(f);  %close file handle
allsizes = [dsizes; esizes];    %allsizes is the concatenation of both size profiles

xmin = min(allsizes);
xmax = max(allsizes);
set(0, 'DefaultAxesFontName', 'Times New Roman');
set(0, 'DefaultAxesFontSize', 18);
figure(1); hist(allsizes, 25); title('Histogram of pizza diameters, in inches');
axis([xmin xmax 0, 40]);
figure(2); hist(dsizes, 25); title(sprintf('%s pizza diameters, in inches', pmans{1}));
axis([xmin xmax 0, 40]);
figure(3); hist(esizes, 25); title(sprintf('%s pizza diameters, in inches', pmans{2}));
axis([xmin xmax 0, 40]);