Question: 1 Debugging a function ( 4 marks ) What this question is checking? Recently in class you have been introduced to programming in general, and
Debugging a function marks
What this question is checking? Recently in class you have been introduced to programming
in general, and Matlab in particular. Programming requires a number of minor skills seldom taught
in lower level courses, such as interpreting errors, seeking tools and building flows. This question is
designed to test your understanding of these skills, and give you a chance to practice them.
a The doctor has prescribed your grandmother a vitamin tablet once every two days and iron
tablets once every five days in August.
Your brother wrote a M M TLAB function called 'TabletHelper' to help remind your grand
mother which tablets to take on a given day. The program should print the date for each day
of the month. If the date is a multiple of next to the date it should also print "Vitamins".
If the date is a multiple of next to the date it should print "Iron". If the date is a multiple
of both and next to the date it should print "Vitamins and Iron".
The program is shown below.function TabletHelper
for i: dispnumstri'Vitamins' dispnumstri'Iron' dispnumstri'Vitamins and Iron' dispnumstriendThis code has mistakes! Find all of the mistakes in your brother's code, explain why each
is incorrect, and suggest fixes for each mistake. Also submit the final correct version of the
function.
Note: We do not want you to write a new function that will work correctly. key skill in
programming is being able to fix errors, not just start from scratch each time!
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
