INDIVIDUAL] Debugging code is an essential programming skill. In this question,
ID: 3680608 • Letter: I
Question
INDIVIDUAL] Debugging code is an essential programming skill. In this question, you are given a MATLAB For example, one should be able to use the function as follows. a. Average value of an array can be calculated in several ways. Please correct the code and make sure averagel, progran with several erors. Pleaey to identily them, expiain wh i wroug, and how it can program with several errors. Please try to identify them, explain what is wrong, and how it can be corrected. average2 and average3 give the same result. a = 125; b = 342; c = 45 ; d = 512; num [a b c d e]; average1 mean [num average2 = a + b + c + d + e / 5 average3 myHean (num) Please save the following code as myMean.m in your workspace. function [m] = myMean (x) n-length (x) ; m avg (x,n); end function m - avg(x,n) m sum(x)/m; endExplanation / Answer
a)
1) change average2 = a+b+c+d+e/5 to average2 = (a+b+c+d+e) / 5
2) change m = sum(x) / m; to m = sum(x) / n ;
b)
change num(5) to num(i) in all the three places.