clear rulenumber* changetoo*
ruletotalvalue=inputdlg({'Rule Number','Number of Possible Colors(Cell Values)'},'',1);
rulenumber=ruletotalvalue{1};
rulecolors=ruletotalvalue{2};
rulenumber=eval(rulenumber);
rulecolors=eval(rulecolors);
possiblestates=((rulecolors-1)*3)+1;
rulenumberbinaryfirst=dec2base(rulenumber,rulecolors,possiblestates);
rulenumberbinary=num2matrix(rulenumberbinaryfirst);
% Rulenumberbinary is a number with as many digits as states.
% The rule number converted to base "rulecolors" equals the results for each
% possible state in that rule.
% Rulenumber equals base2dec('rulebinary',rulecolors)
% You can generate rulebinary then solve for the rule number.