Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are going to write a MATLAB program to read in an Excel spreadsheet and comp

ID: 3678993 • Letter: Y

Question

You are going to write a MATLAB program to read in an Excel spreadsheet and compute your average grade based on all grades that you know thus far. The spreadsheet will be called “MyGrades.xlsx” and it will have 5 columns. Column A will contain homework scores and there will be 42 rows worth of data (representing 42 homework grades). Column B will contain quiz scores and there will be 16 rows worth of data (representing 16 quiz grades). Column C will contain test scores and there will be 3 rows worth of data. Column D will contain the final exam score and there is only one of that. The last column, Column E will contain the semester project score and there will only be one of that as well. There will be no column headers in the Excel file, just numbers representing grades. Also, you cannot specify a path for your Excel file; it must be saved in your current MATLAB folder.

Your MATLAB code needs to read this data in and then compute your average in the course. It also needs to ask the user their name and then display a statement similar to the following if the user’s name is Kevin:

Kevin, your current grade in the class is 97

Explanation / Answer

fh = fopen('grades.txt', 'r');
line = '';
while ischar(line)
    [first line] = fgetl(fh)

Got this so far:
fh = fopen('grades.txt', 'r');
line = '';
while ischar(line)
    [first line] = fgetl(fh)
    scores = sscanf(line, '%f %f %f %f %f');
    GPA= scores(1:end)/length(scores)
end
xlswrite('grades.xls');
fclose(fh);

MATLAB script that reads the file, calculates the GPA for each student and save the fist name, last name and GPA to an excel file "gpa.xls"
>
> So far all I can come up with is:
>
> fh = fopen('grades.txt', 'r');
> line = '';
> while ischar(line)
> [first line] = fgetl(fh)
Got this so far:

fh = fopen('grades.txt', 'r');
line = '';
while ischar(line)
    [first line] = fgetl(fh)
    scores = sscanf(line, '%f %f %f %f %f');
    GPA= scores(1:end)/length(scores)
end
xlswrite('grades.xls');
fclose(fh);

MATLAB script that reads the file, calculates the GPA for each student and save the fist name, last name and GPA to an excel file "gpa.xls"
>
> So far all I can come up with is:
>
> fh = fopen('grades.txt', 'r');
> line = '';
> while ischar(line)
> [first line] = fgetl(fh)
>

fnam='foo.txt'; % <- your file name...
     s=textread(fnam,'%s','delimiter',' ');
     r=cellfun(@(x) mean(sscanf(x,'%d')),s,'uni',false);
     ix=cellfun(@isnan,r);
     r(ix)=s(ix);
     r=reshape(r.',2,[]).';
     disp(r);
%{
     'John Doe' [ 1]
     'Jane Doe' [2.4]
     'Jill Doe' [2.2]
%}
% now, use XLSWRITE

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);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote