Use of Semicolon in Matlab – Coding Examples

Use of Semicolon in Matlab – Coding Examples

The command window in Matlab works in a very different way compared with other software language compiler. Also, the command window of Matlab® not a ‘compiler’ actually. But if you obtain your codes in a Matlab script, you could test your codes inside the command window of Matlab. So, semicolon has a very important duty in the Matlab coding.

Also, you could use the command window in Matlab as a calculator. Moreover, Matlab is a much more complex calculator. In this text, we will show you what is the difference between ending Matlab codes with a semicolon and without a semicolon. In the command line, there is a difference in this context.

Check: Recommended Books to Learn Matlab®

What is The Duty of Semicolon in Matlab Codes?

>> a = 3;
b = 4;
c = a+b

c =



Firstly, if your Matlab code has a semicolon at the end of each line like above, this means that the ans line will not appear in the command window which will provide a much more clean command window. You could see the results at the Workspace.

But if you don’t put semicolon to the end of your Matlab codes like above shown by red arrows, the results will appear at the command window like above. This is very useful for using Matlab® as a calculator. You could see the results of mathematical calculations in Matlab®.

Beside the use of semicolons in Matlab, Matlab provides very good commands to calculate complex problems. Check the related contents about Matlab to learn to code and solve mathematical problems in Matlab.

‘continue’ Command in Matlab® Programming

‘break’ Command in Loops in Matlab® Programming

Multiplication with prod() Command in MatLab

Use of ‘sparse()’ Command in Matlab®(Illustrated Expression)

Creating Vectors with Logspace() Command in Matlab®(Illustrated Expression)


Above all, Do not forget to leave your comments and questions below about the use of the semicolon in Matlab below. 

If you want further coding examples about semicolon in Matlab®, inform us in the comments.

This article is prepared for completely educative and informative purposes. Images used courtesy of Matlab®

Your precious feedbacks are very important to us.

Last Updated:


Leave a Reply

Your email address will not be published.