Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

More Books

Students also viewed these Databases questions

Question

Whats important about that?

Answered: 1 week ago

Question

\f

Answered: 1 week ago