Lab2 - 1901072-Power System
Lab2 - 1901072-Power System
𝑬𝒙𝒑𝒆𝒓𝒊𝒎𝒆𝒏𝒕 𝑵𝒐: 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)
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.