Where: Look in the Matlab Primer for Any of This Information

Total Page:16

File Type:pdf, Size:1020Kb

Where: Look in the Matlab Primer for Any of This Information

Leader: James MATLAB If Statements Course: ChE 160 Supplemental Instruction Instructor: Heinen/ Stiehl/ Brenza Iowa State University

Where: Look in the Matlab primer for any of this information

Discussion The first element when understanding how to program. If statements are used so extensively, that mastering them early will save you an incredible amount of headache.

Concept Questions How do you end an If statement? What is the difference between Else and Elseif?

Review For the following: What is the value for z when input = 18? What are the values for a, b and c? What is the value for z when input = 190? a=2; b = 22; c = 199; if a < 4 z = input('Enter a number: '); c=17; if z == 40 elseif b~=c z=z*4 c=26 elseif z < 20 end z=z/3 else z=176 end What is the value for z when: z=4? z=60? What are the errors in this code? z= 120? j = 16; k = 44e-6; z = InputBox ("Enter a number") if k = 4 If z > 110 Then j = 16 z = z - 4 else q ~= 4 ElseIf z < 40 Then j = 2 z = z * 6 else k => 16 Else j =1 z = 176 end End If

Exam Prep Just screw around with the IF statements. The best way to understand is to just try using them over and over again.

1060 Hixson-Lied Student Success Center v 515-294-6624 v [email protected] v http://www.si.iastate.edu

Recommended publications