02 - for k = 1:length(A) A(k) = 2 end...

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

View Full Document Right Arrow Icon
CS 1371 M01 Recitation 9/02 if myAnswer == true printMe = 1; else printMe = 0; end ----------------------- if (logical expression) is true this code runs else if (logical expression) is true this code runs else end -------------------- if myAnswer == 2 printMe = 5; elseif myAnswer == 5 printMe = 2; else printMe = 0; end ---------------------- switch myAnswer case 2 printMe = 5; case 5 printMe = 2; otherwise printMe = 0; end -------------------- D = 3 switch(D) case 3 (aka if D == 3) [run this code]
Background image of page 1

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

View Full DocumentRight Arrow Icon
case 0 [run this code] otherwise [run this code] end ---------------------- Month = # switch Month case 1 value = 1 case 2 value = 4 --------------------- ****mod(number, divided by) --------------------- number # var = mod(number, 2); switch var case 0 even = true case 1 even = false end ---------------------- A = ones(1,5) A(k) = 2 where k is the length of the vector
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for k = 1:length(A) A(k) = 2 end -----------------------vec = [2 4 7] out = [ ] for i = vec out = [i, out] end--------------------********* for counter = 1:4 %execute sequence 4 times day = # if (day==1) %Sunday itIs = 'Weekend' elseif (day==7) %Saturday itIs = 'Weekend' else itIs = 'Weekday' %Monday - Friday end switch day case 1 dayName = 'Sunday' case 2 dayName = 'Monday'----------------------********* and && both have to be true or ll either or can be true not ~ true = false and false = true element-wise ops----------------------********* done = false; while -done day = # if (day == 0) done = true; else &check for weekend if (day==1) &Sunday itIs = 'Weekend' elseif (day==7) %Saturday itIs = 'Weekend' else itIs = 'Weekday' %Monday - Friday end...
View Full Document

This note was uploaded on 10/20/2008 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Institute of Technology.

Page1 / 3

02 - for k = 1:length(A) A(k) = 2 end...

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

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