Programming Languages Section

Hello World with MATLAB

Card image
Post by Amina Delali, November 21th, 2022

Some Facts

MATLAB is at the same time, a programming language and a computing environment. It is used mostly by engineers and scientists for numeric computations, and modeling.

So, with MATLAB you can do mathematical computations, plotting, symbolic computing, model-based design, and interfacing with code written in other languages.

All the functionalities of MATLAB are organized in Toolboxes, and depending on the installed toolbox, you will have a certain set of MATLAB capabilities.

The MATLAB software is not free, so you either have to by it, or use your organization's license. If you buy the software, you will have to choose the set of Toolboxes that best fits your needs.



How to install MATLAB

For both Windows and Ubuntu, you will have to download the installer, and run it to install MATLAB on your system.

You can have a Free Trial version, but you can also use the Free online version, that comes with only a basic set of Toolboxes, and a monthly hours limit of usage (20 hours per month).

To use it, go to MATLAB Online Page, and click on the Start using MATLAB online button.

You will be asked to create an account, then use the account to log in.

You can run your scripts directly in the command windows, or create files on the MATLAB drive(5 GB storage limit), then run them on the command window. Of course, you can later download or delete your files from the online drive. You can also upload your own files to that drive.

The Hello World Example with MATLAB

We will test the code on the MATLAB online basic environment. So head to your page, and type on your command window the following code:

fprintf("Hello World")

Now, hit return, the message Hello World will be printed (on that same command window).

You can also run your code from a script file. Simply, click the New Script button, from the Home top menu bar. Click on the tab corresponding to that file, then write the same code above:

fprintf("Hello World")

Hit the CTRL + S buttons, then type the name of the file. In our case, it will be hello.m, then click Save.

To run the code, you either hit on the run button from the Editor top menu bar, or on the command window, type in hello, then hit Return.



Additional Information

For more information about the MATLAB language and the corresponding code, you can check the following pages:

Something to say ?

If you want to add something about the MATLAB language or about this post, please feel free to do it by commenting below 🙂 .