function [m,A,B]=markquiz2(filename,an) % filename is character string representing excel file, first column=student ID, second and remaining columns=answer in characters %an=vector of correct answers. Like markquiz only answers are simply compared with % correct answers. for example m=markquiz('quiz.xls') [A,B]=xlsread(filename); % A contains the numeric data and B contains the text data. %assume that the first column is ID and the second is the name n=size(B); mark=zeros(n(1)-1,n(2)-1); m=length(an); % mark the questions but not the first row(my answers) for i=2:n(1) for j=3:(2+m) t=eval(char(B(i,j))); mark(i,j-1)=(t==an(j-2)); end end m=[A(:,1) mark sum(mark,2)]; %filename=input('enter filename for marks output file ','s') %dlmwrite(filename,m,',') %writes results to corresponding filename.