LECTURE_8_CS113_2010 - 1 CS113 Introduction to Computing...

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 CS113 Introduction to Computing for Engineers Iteration 2 REVIEW FROM LAST LECTURE 3 REVIEW FROM LAST LECTURE 4 REVIEW FROM LAST LECTURE 5 REVIEW FROM LAST LECTURE 6 REVIEW FROM LAST LECTURE 7 CONDITIONAL STATEMENTS APPLIED TO MATRICES >> A = [ 0.5, 6.0, -12.6, 34.6, 99.3, -6]; >> B=(A<5); WHAT WILL B RETURN? 8 CONDITIONAL STATEMENTS APPLIED TO MATRICES >> A = [ 0.5, 6.0, -12.6, 34.6, 99.3, -6]; >> B=(A<5); The conditional statement will apply to every element in a vector or matrices. For every number in A that is true B will have a 1 in that place and for every number that is false B will have a 0 in that place. >> B B = 1 0 1 0 0 1 >> 9 CONDITIONAL STATEMENTS APPLIED TO MATRICES >> A = [ 9.0, 6.0, -5; 12, 9, 4; -1, 62, 11]; >> B=(round(A/2)==(A/2)); WHAT WILL B RETURN? (SIDE NOTE: ROUNDING OFF NUMBERS) 1. round(x) % rounds x off to the nearest integer 2. floor(x) % rounds x off towards the lower integer 3. ceil(x) % rounds x off towards the higher integer Examples: >> round(4.6) ans=5.0 >> floor(4.6) ans=4.0 >> ceil(5.1) ans=6.0 10 CONDITIONAL STATEMENTS APPLIED TO MATRICES >> A = [ 9.0, 6.0, -5; 12, 9, 4; -1, 62, 11]; >> B=(round(A/2)==(A/2)); WHAT WILL B RETURN? B = 0 1 0 1 0 1 0 1 0 11 Introducing the FOR-END Command 12 Introducing the for – end loop 12 Introducing the for – end loop 13 Introducing the FOR-END 14 Introducing the FOR-END 15 Introducing the FOR-END 16 Introducing the FOR-END 17 Introducing the FOR-END 18 Introducing the FOR-END 19 Introducing the FOR-END 20 Introducing the FOR-END 21 Example 1: The FOR Structure Step 1: Describe problem: Write a MatLab program to • calculate the area and the circumference of TEN circles • enter the radius of each as an input variable • output radius, area and circumference IF the area is greater than 20 square units....
View Full Document

{[ snackBarMessage ]}

Page1 / 36

LECTURE_8_CS113_2010 - 1 CS113 Introduction to Computing...

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

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