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

matlabProgram Description: This program will read in the original data from the

ID: 2248760 • Letter: M

Question

matlabProgram Description:

This program will read in the original data from the Feb_6_2009 sheet

contained in the Excel file named ClassList.xlsx . This file contains the

student number and number of absences recorded for each student as of Feb

6, 2009.

Perform the following operations with this data:

1. Output the Feb 6 attendance data to the command window with a neat format.

2. Output a list of students with 1 or 2 absences in the command window

   who will be sent warning letters.

3. Output a list of students with >=3 absences in the command window

   who will be dropped from the course .

4. Remove the students with >=3 absences from the class list and output

   this updated class list to the command window and the Feb_13_2009 sheet in

   the ClassList.xlsx file.

3. Print out your Excel sheets and the contents of your command window.

4.   A sample of the command window is shown below.

Class List for February 6, 2009 Student Number Absences 50100 0 50101 4 50102 2 50103 0 50104 1 50105 3 50106 0 50107 2 50108 3 50109 0 50110 1 50111 3 50112 0 50113 0 50114 1 50115 3 50116 0 50117 4 50118 0 50119 2 50120 2 50121 0 50122 0 50123 0 50124 3 50125 3 50126 4 50127 2 50128 0 50129 3 50130 1

Explanation / Answer

clc;
close all;
clear all;

stu_id = xlsread('ClassList.xlsx','Feb_21_2010','A4:A34'); %Student Id
attend_list = xlsread('ClassList.xlsx','Feb_21_2010','B4:B34'); %attendance

fprintf('Student Id Attendance ');
for i = 1:1:length(stu_id);
    fprintf(' %d %d ',stu_id(i),attend_list(i));
end

warning_attend=[];
warning_stuid=[];
fprintf(' STUDENTS WITH 1 or 2 ABSENCES... WARNING!!! ');
fprintf('Student Id Attendance ');
for i = 1:1:length(stu_id);
    if(attend_list(i) >=1 && attend_list(i) <=2)
        warning_attend = [warning_attend;attend_list(i)];
        warning_stuid = [warning_stuid;stu_id(i)];
        fprintf(' %d %d ',stu_id(i),attend_list(i));
    end      
end

dropout_attend=[];
dropout_stuid=[];
fprintf(' STUDENTS WITH >2 ABSENCES... YOU HAVE TO DROP!!! ');
fprintf('Student Id Attendance ');
for i = 1:1:length(stu_id);
    if(attend_list(i) >=3)
        dropout_attend = [dropout_attend;attend_list(i)];
        dropout_stuid = [dropout_stuid;stu_id(i)];
        fprintf(' %d %d ',stu_id(i),attend_list(i));
    end      
end

updated_stu = [];
updated_attend = [];
fprintf(' UPDATED STUDENT LIST ');
fprintf('Student Id Attendance ');

for i = 1:1:length(stu_id)
    flag = 1;
    for j = 1:1:length(dropout_attend)
        if stu_id(i) == dropout_stuid(j)
            flag = 0;
            break;
        end
    end
    if flag == 1
        fprintf(' %d %d ',stu_id(i),attend_list(i));
        updated_stu = [updated_stu;stu_id(i)];
        updated_attend = [updated_attend;attend_list(i)];
    end
end

delete ClassList1.xlsx
TOPROW1 = 'List of students warned on Feb 21,2010';
TOPROW2 = 'List of students dropped on Feb 21,2010';
TOPROW3 = 'List of students updated on Feb 21,2010';

xlswrite('ClassList1.xlsx',{TOPROW1},'Warning','A1')
xlswrite('ClassList1.xlsx',{'STUDENT NUMBER'},'Warning','A3')
xlswrite('ClassList1.xlsx',{'ATTENDANCE'},'Warning','B3')
xlswrite('ClassList1.xlsx',warning_stuid,'Warning','A4')
xlswrite('ClassList1.xlsx',warning_attend,'Warning','B4')
xlswrite('ClassList1.xlsx',{TOPROW2},'Dropout','A1')
xlswrite('ClassList1.xlsx',{'STUDENT NUMBER'},'Dropout','A3')
xlswrite('ClassList1.xlsx',{'ATTENDANCE'},'Dropout','B3')
xlswrite('ClassList1.xlsx',dropout_stuid,'Dropout','A4')
xlswrite('ClassList1.xlsx',dropout_attend,'Dropout','B4')

xlswrite('ClassList1.xlsx',{TOPROW3},'Feb_21_2010','A1')
xlswrite('ClassList1.xlsx',{'STUDENT NUMBER'},'Feb_21_2010','A3')
xlswrite('ClassList1.xlsx',{'ATTENDANCE'},'Feb_21_2010','B3')
xlswrite('ClassList1.xlsx',updated_stu,'Feb_21_2010','A4')
xlswrite('ClassList1.xlsx',updated_attend,'Feb_21_2010','B4')


%REPLACE ClassList1.xlsx with ClassList.xlsx