This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full 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 FOREND Command 12 Introducing the for – end loop 12 Introducing the for – end loop 13 Introducing the FOREND 14 Introducing the FOREND 15 Introducing the FOREND 16 Introducing the FOREND 17 Introducing the FOREND 18 Introducing the FOREND 19 Introducing the FOREND 20 Introducing the FOREND 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
This note was uploaded on 02/29/2012 for the course CSC 113 taught by Professor Phillipregali during the Fall '10 term at Catholic University of America.
 Fall '10
 PhillipRegali

Click to edit the document details