Matlab codes quick questions
Read each question carefully. Questions 1-3 are 10 points each. Question 4 is 20 points. Total 50 points.
For Questions 1-2, submit your answers in a single MS Word or PDF file. For Question 3-4, submit the two written script files along with the MS Word or PDF file. Three files should be submitted.
Do NOT submit screenshots.
Draw the flow diagrams for for loop and while loop, separately. (10 points)
What does a jump statement do to an iteration statement? What is the difference between a break statement and a continue statement? (10 points)
The Taylor series for the exponential function ex is given below. Write a script file using the proper iteration statement to read in a number x and calculate its exponential using Taylor series for the first 10 terms. (10 points)
1 + β (π₯^π
π! )
β
π=1
Write a script program using a proper loop statement to perform the following tasks: (20 points)
(1) Per-determine a random integer (rand_int) between [0-9] by the program (hint: use randi() ).
(2) Let the user guess a number (number) entered from the keyboard to be compared with the random integer (rand_int).
(3) If the value of number matches the value of rand_int, the program should display a message βBingo! The guessing is stopped by the program.β and terminate.
(4) If the two values of number and rand_int are not matched, the program should ask whether the user wants to keep guessing by displaying βWrong guessing… try again?β.
(5) To continue guessing, a character βYβ or βyβ should be entered from the keyboard; to stop guessing, a character βNβ or βnβ should be entered, and display βThe guessing is stopped by the user.β.