Review and More MATLAB Programming Practice


Exam review

Algorithms and pseudo-code

Input

 

Count-controlled iteration using for loop

 

Conditional execution

 

 

 

 

Testing and debugging

 

 

Successive numeric approximation

 

 

 


Numeric approximation algorithms

What are the next two approximations that Newton's method finds for f(x) = x2 - 2x + 1 and an initial guess of 3?

 

 

 

 

 

 

 

 


Code tracing

What is displayed in the Command Window when the following code fragment is executed?

p = [ 1, 2 ];
for n = [ 3 4 7 ]
    while p(1) < n
        if p(2) < n
            disp(p)
        end
        p = p + 1;
    end
end
disp(p)

 

 


Code writing

Write a program that allows a user to play a game of ROCK-PAPER-SCISSORS against the computer.