Tip #1: colon notation
The
colon notation is very helpful when generating vectors: start:step:end
(step is optional)
10:20 ==> [10 11 12 13 14 15 16 17 18 19 20]
10:5:20 ==> [10 15 20]
10:6:20 ==> [10 16]
0:0.2:1 ==> [0 0.2 0.4 0.6 0.8 1.0]
Note that 0:0.2:1 is equivalent to colon(0, 0.2, 1)
Problem: You cannot use ellipsis within a string, for example:
![]()
MATLAB often uses color to indicates how it understands your code.
See the red that turns into black and then purple above? That suggests a problem.Solution? Break your statement up into separate disp commands, like this
(note the code below is part of an m-file, rather than typing it directly in the command window):
![]()
** Important Note about MATLAB's debug mode **
Sometimes, when there is an error in your program, MATLAB decides to go into
Debug mode. You will know this because the MATLAB prompt in the Command Window
has a K in front of it like this:
K>>
To get out of Debug mode, you can select Exit Debug Mode from the
Debug menu (as shown below).
Debug
mode sometimes also puts breakpoints into your code, these will show
up as little red filled circles to the left of your line of code.
To get rid
of these breakpoints, select Clear Breakpoints from All Files from the Debug menu.
(Later on in the semester, we will use Debug mode to help us understand how
our programs are working, but for now, we simply want to exit out of Debug mode
when MATLAB puts us in it).
cs112/ folder. cs112/drop/assign1 folder.