# MATLAB code to prepare database of n students for 5 subjects

Course Details

Field of Study: Electronics Engineering
Course Name: Simulation and Computational Laboratory
Description: MATLAB code to prepare database of n students for 5 subjects and if their mark is above 250 their status is “passed” else “Failed”.

MATLAB Code
% A matlab Program that prepares a database of n students for 5 subjects
clc;
clear;
n = input(‘For how many students do you want to prepare a database? ‘);
for i = 1:n
reg(i,1) = input(‘Enter the registration No of the student: ‘ );
end

for k = 1:n
for j = 1:5
sub(k,j) = input(‘Enter the marks of each subjects of all the students: ‘ );
end
end

total=sum(sub,2);

for m = 1:n
if total(m,1) >= 250
status(m,1) = 1;
else
status(m,1) = 0;
end
end

clc;
disp(‘============================================’);
disp(‘The data base of the students is given below’);
disp(‘============================================’);
disp([‘Reg No ‘ ‘Sub 1 ‘ ‘Sub 2 ‘ ‘Sub 3 ‘ ‘Sub 4 ‘ ‘Sub 5 ‘ ‘Total ‘ ‘Status’]);
s=[reg sub total status];
disp(s);
disp(‘Note:’);
disp(‘Status = “1” is “Passed”‘);
disp(‘Status = “0” is “Failed”‘);

The sample output for 7 students is shown below

Previous Post: C programming code to display asterisk in a rectangle pattern

December 2, 2014 - In

Next Post: MATLAB code for continuous time convolution

December 4, 2014 - In

### Related Posts

#### Matlab Code for Computer Exercise C8.6 Monson H. Hayes Statistical DSP

• December 2, 2014