Question
How would i code this in MatLab

3. Write the program, openclasses.m, where you start by creating a structured array called class which contains the information in the following table (note: seats should be a single fieldname with a (1x2) array inside it). Class Title Introduction to Engineering Computers in Psychology Writing and Rhetoric Beginning Spanish Introduction to Africana Studies Number Seats (Max, Enrolled) 10111 (45, 32) 20000 (28, 25) 12100 (14, 14) 10101 (19,13) (36, 32) 20082 From this information, check to see which classes have at least 5 open spots so you and your study group can enroll together. Display the names of the courses available in the command window. You should use referencing into the structure to create this list of courses
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Variable Description:

  • classes - structures array to store the details of each class, its number and the number of seats available and enrolled
  • class_title - title of the class
  • number - class number
  • seats - a 1x2 array to store the max seats and the seats that have already been enrolled
  • i - control variable for loop

Code -

classes(1).class_title = 'Introduction to Engineering';

classes(1).number = 10111;

classes(1).seats = [45 32];

classes(2).class_title = 'Computer Science';

classes(2).number = 20000;

classes(2).seats = [28 25];

classes(3).class_title = 'Writing and Rhetoric';

classes(3).number = 12100;

classes(3).seats = [14 14];

classes(4).class_title = 'Beginning Spanish';

classes(4).number = 10101;

classes(4).seats = [19 13];

classes(5).class_title = 'Introduction to African Studies';

classes(5).number = 20082;

classes(5).seats = [36 32];

for i = 1:5

if classes(i).seats(1) - classes(i).seats(2) >= 5

disp(classes(i).class_title);

end

end

classes (1).class_titleIntroduction to classes (1).number = 10111; c1a33e3 (1) .зеасз [45 32]; Engineering classes (2).class

Add a comment
Know the answer?
Add Answer to:
How would i code this in MatLab 3. Write the program, openclasses.m, where you start by...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT