
numq = length(question);
for ii = 1:numq
  if strcmp(type{ii},'1=disagree,4=agree')
    kk = indices{ii};
    dd = data(:,kk);
    jj = ~strcmp(dd,'');
    dd = cellfun(@str2num,dd(jj));
    bar(1:4,hist(dd,1:4))
    axis([0.5 4.5 0 400])
    title(question{ii});
    set(gca,'xtick',1:4,'xticklabel',{'disagree','','','agree'});
    print('-depsc',header{kk});
    print('-djpeg',header{kk});
  elseif strcmp(type{ii},'1=ill-prepared,4=well-prepared')
    kk = indices{ii};
    dd = data(:,kk);
    jj = ~strcmp(dd,'');
    dd = cellfun(@str2num,dd(jj));
    bar(1:4,hist(dd,1:4))
    title(question{ii});
    set(gca,'xtick',1:4,'xticklabel',{'ill-prepared','','','well-prepared'});
    print('-depsc',header{kk});
    print('-djpeg',header{kk});
  elseif strcmp(type{ii},'yesno')
    kk = indices{ii};
    dd = data(:,kk);
    jj = ~strcmp(dd,'');
    dd = dd(jj);
    nn = zeros(size(dd));
    nn(strcmp(dd,'Yes'))=1;
    bar(0:1,hist(nn,0:1))
    title(question{ii});
    set(gca,'xtick',0:1,'xticklabel',{'no','yes'});
    print('-depsc',header{kk});
    print('-djpeg',header{kk});
  elseif strcmp(type{ii},'multiplechoice')
    kk = indices{ii};
    nn = zeros(size(kk));
    for jj = 1:length(kk)
      nn(jj) = sum(strcmp(data(:,kk(jj)),'1'));
    end
    [nn jj] = sort(nn,'ascend');
    barh(1:length(nn),nn);
    set(gca,'ytick',1:length(nn),'yticklabel',options{ii}(jj));
    title(question{ii});
    print('-depsc',['Question' num2str(ii)]);
    print('-djpeg',['Question' num2str(ii)]);
  else
    fprintf(1,[question{ii} '\n']);
  end
end
