Sunday, January 31, 2010

switch, otherwise, disp

more things i should've known and/or always forget:

switch is supposed to be better than a list of if, elseifs. i can think of some cases where i should've used this.

a very clear and not flashy 3 minute video explaining this:
http://blogs.mathworks.com/videos/2008/01/02/matlab-basics-switch-case-vs-if-elseif/

otherwise is the default value of switch (also explained in video)

the video shows the use of disp, which is a very simple command to display text that i have forgotten in the past and spent a long time trying to remember. it is particularly good if you want to print things out to the screen to know how your program is running (e.g. error messages, transient values, loop number, etc.).

disp('SIGH');

No comments:

Post a Comment