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

Plz write codes only using MATLAB 1. Consider a (very small) class with the foll

ID: 3738470 • Letter: P

Question

Plz write codes only using MATLAB

1. Consider a (very small) class with the following students and their GPA's. Student name GPA Alfonso Bedoya Tonya Harding Warren Harding Warren Piece 2.77 2.30 3.25 Write a MATLAB program, ProcessStudents.m, that constructs students, a one-dimensional array of structures with fields named firstname, lastname, and gpa. It should then loop through each element in the array and call a function DisplayStudentRecord (theStudent) (which you also need to write) that displays data for each student on the screen. This function should take a single student structure as an argument. function DisplayStudentRecord(theStudent) % function Display. StudentRecord (theStudent) % displays theStudent, firstname, theStudent,lastname, and theStudent.gpa

Explanation / Answer

Program

s.firstname='first';
s.lastname='last';
s.gpa=1;
student = repmat(s,1,4);

function DisplayStudentRecord(Student)
fprintf(Student.firstname); fprintf(" ");
fprintf(Student.lastname);
disp(Student.gpa);
end
student(1).firstname = 'Alfonso';
student(2).firstname = 'Tonya';
student(3).firstname = 'Warren';
student(4).firstname = 'Warren';

student(1).lastname = 'Bedoya';
student(2).lastname = 'Harding';
student(3).lastname = 'Harding';
student(4).lastname = 'Piece';
student(1).gpa = 3.43;
student(2).gpa = 2.77;
student(3).gpa = 2.30;
student(4).gpa = 3.25;

[r,c]=size(student);
for i=1:c
DisplayStudentRecord(student(i));
end

output

Alfonso Bedoya 3.4300
Tonya Harding 2.7700
Warren Harding 2.3000
Warren Piece 3.2500

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote