x = round(rand(100,1)*4)+1;                 % generate 100 random numbers
                                            % within the 1-5 range
ctrs = [1, 2, 3, 4, 5];                     % an array that keeps the coding
                                            % of the values we expect
expectedCounts = [20, 20, 20, 20, 20];      % the expected freq. for each value
[h,p,st] = chi2gof(x,'ctrs',ctrs,'expected',expectedCounts)