Question: Pass Task 6 Debugging MATLAB Code Enter the MATLAB program below containing errors in a new script named PassTask6.m using the MATLAB editor. % Program

Pass Task 6 Debugging MATLAB Code Enter the MATLAB program below containing errors in a new script named PassTask6.m using the MATLAB editor. % Program to sum positive elements of an array % ten random integers between -10 and 100 v = round(-10.0 + 110*rand(1,30)); % sum all positive elements of array v for k = 1:1:length(v) if (v >= 0) result = result + v end end disp(v); disp('The sum of the positive elements in v is: '),disp(result); 1) Run the program and correct any syntax errors. 2) Using the MATLAB Editor, set breakpoint at the lines with the statements: for k = 1:1:length(v) result = result + v 3) Debug the program by stepping through the program and watching the workspace and command window for incorrect behaviour. Correct any logic errors. Reset the breakpoints if necessary and rerun the corrected script watching the workspace and command window. 4) Correct any style errors and comment on the errors. Show the correct program and explain the errors you found in the original program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!