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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started