0% found this document useful (0 votes)
12 views3 pages

Lab2 - 1901072-Power System

The document describes a MATLAB code that calculates the average of the best 3 out of 4 class test (CT) marks for students, writes the results to an Excel file, and automates the process to make it easier for teachers to prepare results as it eliminates manual errors. The code takes the CT marks as input from one Excel file, calculates the averages, and writes the output to another Excel file along with the student roll numbers.

Uploaded by

Istiak Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Lab2 - 1901072-Power System

The document describes a MATLAB code that calculates the average of the best 3 out of 4 class test (CT) marks for students, writes the results to an Excel file, and automates the process to make it easier for teachers to prepare results as it eliminates manual errors. The code takes the CT marks as input from one Excel file, calculates the averages, and writes the output to another Excel file along with the student roll numbers.

Uploaded by

Istiak Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Rajshahi University of Engineering & Technology (RUET)

Department of Electrical & Electronic Engineering


Course no: EEE 3211
Course Title: Power System
I

𝑬𝒙𝒑𝒆𝒓𝒊𝒎𝒆𝒏𝒕 𝑵𝒐: 02
𝑬𝒙𝒑𝒆𝒓𝒊𝒎𝒆𝒏𝒕 𝑵𝒂𝒎𝒆: 𝐶𝑇 𝐴𝑣𝑒𝑟𝑎𝑔𝑒 𝐶𝑎𝑙𝑐𝑢𝑙𝑎𝑡𝑖𝑜𝑛 𝑎𝑛𝑑 𝑊𝑟𝑖𝑡𝑖𝑛𝑔 𝑖𝑛 𝐸𝑥𝑐𝑒𝑙 𝐹𝑖𝑙𝑒 𝑢𝑠𝑖𝑛𝑔
𝑀𝐴𝑇𝐿𝐴𝐵

SUBMITTED BY SUBMITTED TO
Name: Md. Istiak Ahmed Md. Rashidul Islam
Roll: 1901072 Assistant Professor
Section: B Department of Electrical & Electronic
Engineering,
Department: EEE
Rajshahi University of Engineering & Technology
Session: 2019-2020
(RUET)

Date of Experiment: 09/10/2023


Date of Submission: 16/10/2023
Experiment No: 02
Experiment Name: CT Average Calculation and Writing in Excel File using MATLAB
Introduction: At RUET, students give 4 class tests(CT) and the best 3 marks out of 4 class
tests are selected and the average marks of that is added with the marks obtained at the
semester final. This calculation is a monotonous process and often lead to make mistakes by
accident by the teachers. In this experiment, we have developed a MATLAB code to perform
the calculations using MATLAB which will automatically write the average marks on an
excel file making it easier for the teachers to prepare results where they only have to input the
obtained numbers on the CTs.

Matlab Codes:
Code
clc;
clear;
cd('C:\Users\sakib\OneDrive\Desktop\') %changing the directory
inputFilePath = 'C:\Users\sakib\OneDrive\Desktop\CT_Marks.xlsx'; % Define file
paths
outputFilePath = 'C:\Users\sakib\OneDrive\Desktop\Average_Marks.xlsx'; % Define
file paths
[A,~,~] = xlsread(inputFilePath); % Load data and calculate size
[row, column] = size(A);
B = sort(A, 2, 'descend'); % Sort A in descending order
C = B(:, 2:column-1); % Extract columns 2 to (column-1) from B
Avg = round(sum(C, 2) / 3); % Calculate average and round
Roll = A(:, 1); % Extract specific columns from A
CT = A(:, 2:5);
col_header = {'Roll', 'CT 1', 'CT 2', 'CT 3', 'CT 4', 'Average'}; % Define column
headers
xlswrite(outputFilePath, col_header, 'sheet1', 'A1'); % Write data to Excel file
xlswrite(outputFilePath, [Roll, CT, Avg], 'sheet1', 'A2'); % Write data to Excel
file

Roll CT 1 CT 2 CT 3 CT 4
1901071 3 16 20 17
1901072 12 18 15 15
1901073 13 12 16 16
1901074 20 13 18 12
1901075 20 20 12 3
1901076 15 12 13 12
1901077 16 13 17 13
1901078 12 18 15 20
1901079 13 12 16 18
1901080 13 13 18 3
Table 01: Input File in Excel
Roll CT 1 CT 2 CT 3 CT 4 Average
1901071 3 16 20 17 18
1901072 12 18 15 15 16
1901073 13 12 16 16 15
1901074 20 13 18 12 17
1901075 20 20 12 3 17
1901076 15 12 13 12 13
1901077 16 13 17 13 15
1901078 12 18 15 20 18
1901079 13 12 16 18 16
1901080 13 13 18 3 15
Table 02: Output File in Excel

Discussion and Conclusion: The provided code can be effortlessly adapted to compute the
average of various sets of marks, whether they be CT marks, quiz scores, or exam results. It
makes effective use of built-in functions like xlsread, xlswrite, sort, sum, round, among
others. The computations were executed seamlessly, and the results were accurately recorded
in an Excel spreadsheet using the xlswrite function.

You might also like