- #26

- 472

- 14

A semicolonat the end of a MATLAB code linestops MATLAB from printing the result of the line. You want to do that so it will not fill the screen with data on lines that you already trust and do not need to see the results. When you are debugging, you might want to remove a semicolon at the end of a MATLAB line to see the results and make sure they are as expected. For instance, to see what is going on in your definition of t and size(t), remove the trailing semicolons to see that t is a 1xN matrix and the size function sets i and j to the dimensions. 'tMin:dt:tMax' is a loop from tMin to tMax in steps of dt.

Matlab:`>> tMin=0; >> tMax=5; >> dt = 1; >> t = tMin:dt:tMax t = 0 1 2 3 4 5 >> [j,k] = size(t) j = 1 k = 6`

I remove trailing semicolons to debug lines and then put them back when I'm confident of that line.

PS. A semicolon inside a matrix definition is different. It starts a new matrix definition row. There may be other uses of the semicolon inside a MATLAB line; I can't think of any now.

excellent! I definitely do not want that :D