SUNY Geneseo Department of Computer Science
“If” Statements, Day 1
Friday, March 28
CSci 120, Spring 2014
Prof. Doug Baldwin
Return to List of Lectures
Previous Lecture
Misc
Web server back, let me know of any problems
Project 2: Comments matter!
- Do… write comments that explain the overall purpose of your program, non-obvious “tricks” in the code, the algorithmic ideas behind it, what variables represent, etc.
- Do Not… write comments that repeat what the code already says, repeat blocks of text from handouts, etc.
- Example of a commented script
Questions?
Quiz 5
Solutions
>> x = 7;
if x > 1
fprintf( 'Hello\n' )
else
fprintf( 'Goodbye\n' )
end
Hello
>> if x > 10
fprintf( 'Yes\n' )
elseif x > 5
fprintf( 'Maybe\n' )
else
fprintf( 'No\n' )
end
Maybe
- The big problem for this vis a vis bisection is that it is discontinuous
- Technically it should also have opposite signs at the endpoints of the interval
“If” Statements
Demo
- The orbits of Earth and Mars
- Distance between Earth and Mars vs time (blue), and derivative of distance (green, scaled to be visible)
See handout for lesson details
Next Lecture