Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chegg will be down for maintenance from 1-2 AM PST on May 22. Were always working hard to help you succeed by making regular updates.

Chegg will be down for maintenance from 1-2 AM PST on May 22. Were always working hard to help you succeed by making regular updates. Thanks for choosing Chegg!

Skip Navigation

home/study/engineering/computer science/computer science questions and answers/ (matlab) %hw6q1.m...

Question: (MATLAB) %hw6q1.m nameEntered = false; studentStruct = []; % variable to repeat the whole proces...

(MATLAB) %hw6q1.m

I need help with the question in the photo.

nameEntered = false; studentStruct = []; % variable to repeat the whole process if some more student to enter repeatOver = true; countStudent = 1; % vectors to store the values in each iteration name_array = []; age_array = []; rating_array = []; % main loop while(repeatOver) % inputting name from user name = inputdlg('Enter your name', 'Input name', [1.5 30], {''}); while nameEntered == false if isempty(name) name = inputdlg('You can''t live this field empty.Please re-enter your name', ... 'Input name', [1.5 30], {''}); else nameEntered = true; end end % adding name to name_array name_array{countStudent} = {name}; ageEntered = false; % asking the 2nd question age = inputdlg('Enter your age', 'Input age', [1.5 30], {''}); while ageEntered == false if isempty(age) age = inputdlg('You can''t live this field empty.Please re-enter your age', ... 'Input age', [1.5 30], {''}); else ageEntered = true; end end age = str2num(age{1}); % adding age to age_array age_array{countStudent} = age; % checking the age for validity if age < 10 uiwait(warndlg('You must be at least 10 years old.')); hw6q1 elseif age > 120 msg = ['If youre really over 120 years old, more power to you', ... ' but I dont quite believe you.']; uiwait(warndlg(msg)); hw6q1 else % Asking the 3rd question quest = 'How much do you like this class?'; title = 'Question'; btn1 = 'Bad'; btn2 = 'Good'; btn3 = 'Best'; class_rating = questdlg(quest,title,btn1,btn2,btn3, 'Good'); % adding rating to rating_array rating_array{countStudent} = {class_rating}; quest_a = 'Whether there is another student to input data?'; title_a = 'More Student ?'; btn_a = 'Yes'; btn_b = 'No'; questdlg(quest_a,title_a,btn_a,btn_b, 'No'); if string(response) == "Yes" countStudent = countStudent + 1; else % creating the structure and adding the arrays to the structure studentStruct.Name = name_array; studentStruct.Age = age_array; studentStruct.ClassRating = rating_array; % generating the filename to store it as .mat file fname = [num2str(countStudent), 'studentsData']; % saving the structure save(fname, 'studentStruct'); repeatOver = false; nameEntered = false; end end end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

7. Discuss the advantages of embedded learning.

Answered: 1 week ago