ENGR 132 - QUIZ8

ENGR 132 - QUIZ8 - ,x) x = 12 y = 27 +2 for having x =...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style 4/24/11 ENGR 132 Wed/Fri 3:30-5:30
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4/24/11 Quiz 8 function [a,b] = My_function(c,d) % header comments a = 0; b = 0; while c <= d counter = 0; while counter < c counter = counter + 1; a = a + counter; end c = a - c; b = c * counter; end >> x=5; >> w=3; >> [x,y] = My_function(w,x) What is output to the command window, when the following code is entered into Matlab? My_function is saved in the current folder.
Background image of page 2
4/24/11 Solution >> x=5; >> w=3; >> [x,y]=my_function(w
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ,x) x = 12 y = 27 +2 for having x = something +2 for having y = something +2 for correct x +2 for correct y +2 for only x and y outputs 4/24/11 Add some fprintf statements to help see what is going on. %put this statement in inner loop after a = a + counter fprintf(Inner Loop: counter=%i, a= %i \n',counter,a,) %put this statement in outer loop after b=c*counter fprintf('Outer Loop: c=%i, b=%i \n',c,b)...
View Full Document

Page1 / 4

ENGR 132 - QUIZ8 - ,x) x = 12 y = 27 +2 for having x =...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online