lecture_20_where_to_go_6p

lecture_20_where_to_go_6p - You have now almost terminated...

This preview shows pages 1–3. Sign up to view the full content.

4/25/2011 1 What have you learned? What do you know? What don’t you know? Where to go from here at UC Berkeley? Where to go from here outside of UC Berkeley? You have now almost terminated E7, so what? Where do you come from? E7 is (most likely) your first training in - Computer programming - Numerical analysis E7 High school ? Your first baby steps with matlab You first learned the workspace, the prompt, how to use the help, etc. Assignment of variables How to start put “numbers in boxes” a = 0 : 0.5 : 10 b = [1, 2, 3] c = [1, 2; 3, 4] student(1).name = ‘Jack’ etc. Functions: basic hygiene of programming That’s why we need hygiene What happens inside a function, stays inside the function. ..

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

View Full Document
2 Remember: ZED IS DEAD! Once you are out of a function, the local variables disappear. If you had a local variable called z, z is dead. And once in a while, we write a script… Yes, OK, once in a while we do things in a not so clean manner. .. Just make sure you know what you are doing. .. But we remember the variables: THEY WILL BE BACK Do not forget that when you write scripts, the variables do not disappear, they are still there It does what it is supposed to do (executes lines of code) As can be seen, the variables inside the script are still in the workspace after the script has finished What if? Branching statements if [my grandmother is not cool] [she will not give me a candy] else if [I am a good boy] [% this means she is cool] [she will give me a candy] else [% this means I am not a good boy] [she will not give me a candy] end Iteration: when loops repeat and repeat a pattern For loops (if you know the number of iterations ahead of time) While loops (if the unknown stopping criterion depends on inside the loop) while (some clause is satisfied) Wh t t t d i th l for (a variable in some set) Whatever you want to do in the loop end Whatever you want to do in the loop end Dr. Kristen Parrish Iteration: when loops repeat and repeat a pattern Modifying a variable in a for loop is usually considered a crime. While loops are dangerous: while(1) will keep you waiting long
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 10

lecture_20_where_to_go_6p - You have now almost terminated...

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

View Full Document
Ask a homework question - tutors are online