You forgot to attach the Excel workbook.
You'd do something like (untested)
[numbers, strings, raw] = xlsread(fileName);
% Then go down numbers looking for valid rows
rollno = numbers(:, 1);
marks = numbers(:, 4);
% Get rid of nan's
blankRows = isnan(rollno);
rollno = rollno(~blankRows);
marks = marks(~blankRows);
% Find the unique rolnos
uniqueNumbers = unique(rollno(~blankRows))
for rn = 1 : length(uniqueNumbers)
thisStudentID = uniqueNumbers(rn);
thisStudentIndexes = rollno == thisStudentID; % Logical vector
% Get average marks for this student
aveMarks(thisStudentID) = mean(marks(thisStudentIndexes));
% Get total marks for this student
totalMarks(thisStudentID) = sum(marks(thisStudentIndexes));
end
Of course you could use splitapply() or grpstats() if you want to do it in a single function call rather than a for loop.
Is it homework?
To Learn MATLAB:
