From: us on
"jeremy meduna" <jeremymeduna(a)msn.com> wrote in message <hoba39$jrq$1(a)fred.mathworks.com>...
> Is what I have here even close to correct??
>
> fh = fopen('grades.txt', 'r');
> line = '';
> ca = {};
> while ischar(line)
> line = fgetl(fh);
> [first line] = strtok(line);
> [last line] = strtok(line);
> grades = sscanf(line, '%f %f %f %f %f %f');
> if 'A'
> grades = 4;
> elseif 'B'
> grades = 3;
> elseif 'C'
> grades = 2;
> elseif 'D'
> grades = 1;
> else
> grades = 0;
> GPA= (grades(1) + grades(2) + grades(3) + grades(4)+grades(5)+grades(6))/length(scores)
> ca = [ca; {first last GPA}];
> end
> end
> xlswrite('grades.xls', ca);
> fclose(fh);

sorry, in my first solution i did not realize that you are using letters(!)...
here's a modified solutions using your exemplary file's content...

fnam='foo.txt'; % <- use your file name...
s=textread(fnam,'%s','delimiter','\n');
s(2:2:end)=regexprep(s(2:2:end),{'A';'B';'C';'D';'F'},{'4';'3';'2';'1';'0'});
r=cellfun(@(x) mean(sscanf(x,'%d')),s,'uni',false);
ix=cellfun(@isnan,r);
r(ix)=s(ix);
r=reshape(r.',2,[]).';
disp(s);
disp(r);
%{
% s =
'John Doe'
'4 4 3 3 2'
'Jane Doe'
'2 1 2 3 4 4'
'Jill Doe'
'2 1 0 0'
% r =
'John Doe' [ 3.2]
'Jane Doe' [2.6667]
'Jill Doe' [ 0.75]
%}
% now, use XLSWRITE

us
 | 
Pages: 1
Prev: error fmincon/interpn
Next: OBTAINING FIR MODEL