Lecture34 - Lecture 34 More Programming in MATLAB...

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

View Full Document Right Arrow Icon
Engineering 101 Engineering 101 Lecture 34 Lecture 34 More Programming in MATLAB More Programming in MATLAB Prof. Michael Falk University of Michigan, College of Engineering
Background image of page 1

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

View Full DocumentRight Arrow Icon
Announcements Announcements Project 8 – Due Weds Dec 6 at 9pm Paper copies and written part due in section on Dec 7 and 8 Projects 5 and 6 will be returned Tues/Weds in lab sections. Exam 3 will be returned on Thurs/Fri in lab sections (some sections may be delayed). Gradebook will be reposted by the end of the week. My office hours today will be 1:30-2:30 in CSE 2636 rather than immediately after class.
Background image of page 2
Announcements Announcements SWE Majors Fair Tomorrow, 7:30-8:30 in Dow 1013 The Majors Fair will be a very informal event with tables throughout the room for each major within engineering. I will have at least one senior (or junior) from each major at their major's table. I am inviting all engineering first and second year students to come talk to the upperclassmen about any majors that they are interested in - what the major really is about, what kind of jobs you can get with it, classes to take, etc. I especially hope that this event will help undecided students make informed decisions about choosing a major.” Lisa Winkel
Background image of page 3

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

View Full DocumentRight Arrow Icon
The If Construct in MATLAB The If Construct in MATLAB The basic form of the if construct in MATLAB is: if control_exp1 statement1 statement2 etc. elseif control_exp2 statement 3 statement 4 etc. else statement 5 statement 6 end Every construct must have an if and an end. The other parts are optional. You can have multiple elseif clauses.
Background image of page 4
Example of the If Construct Example of the If Construct x = input(‘Enter a number’); if x > 0 disp(‘The number is positive’); elseif x < 0 disp(‘The number is negative’); else disp(‘The number is zero’); end
Background image of page 5

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

View Full DocumentRight Arrow Icon
Nested If Constructs Nested If Constructs You can nest if constructs much as you could in C++ if ( pos(x+1, y) == 0) if lastmovex ~= -1 x=x+1; lastmovex = 1; end elseif (pos(x-1, y) == 0) if lastmovex ~= 1; x=x-1; lastmovex = -1; end end
Background image of page 6
The Switch Construct MATLAB also has a switch construct for cases in which you are choosing from a number of alternatives: switch (switch_expr) case case_expr_1 Statement 1 Statement 2 case case_expr_2 Statement 3 Statement 4 otherwise Statement 5 end After executing the particular case the code jumps to after the end. The otherwise part is
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 44

Lecture34 - Lecture 34 More Programming in MATLAB...

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

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