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

MATLAB programing Perform the operations outlined below using Logical Vectors wh

ID: 2080646 • Letter: M

Question

MATLAB programing

Perform the operations outlined below using Logical Vectors when appropriate.

% Program Description:

% This program reads in the original absence data from the Feb_21_2010 sheet contained in the Excel file named ClassList.xlsx This file contains thestudent number and number of   absences recorded for each student as of Feb 21, 2010.

% Perform the following operations with this data

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

% 2. Output a list of students with 1 or 2 absences to the command window who will be sent warning letters and to the Warning Sheet of the Excel file.

% 3. Output a list of students with >=3 absences to the command window who will be dropped from the course and to the Dropped Sheet of the Excel file.

% 4. Remove the students with >=3 absences from the class list and output this updated class list to the command window and a Feb_21_2010 sheet in the ClassList.xlsx file.

Excel file contents    https://docs.google.com/spreadsheets/d/1t0BTl9hSGnf3VRDe95Vc10lQa3hMB7oJZpJJEpT4XNE/edit?usp=sharing

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