Introduction to Matlab
The objective of this article is to have a thorough understanding of how to use Matlab. If you are using a Windows platform, it can be started by double-clicking the Matlab shortcut icon. On UNIX platforms, you can start it by typing Matlab in the operating system prompt. Its start-ups can also be customized. For example, the directory in which it starts or automatically executes Matlab statements can be changed in a script file called startup.m.
To end the Matlab session in the desktop, select File and then use Exit Matlab, or you can type ‘quit’ in the Command Window. You can also run a script file called finish.m.
Naming variables in Matlab: Names of variables in it consist of a single letter succeeded by the desired number of digits, letters, underscores. Here we need to remember that it is a case-sensitive environment.
Saving the work: ‘save’ command can be used for saving the variables in our workspace. The file is saved as .mat extension in the current directory.
Matlab documentation: It provides its users with a number of online documents for any help. We need to select ‘Matlab Help’ which is available in the Help menu inside Matlab.
The Matlab documents are organized into below main topics:
- Desktop Tools & Development Environment: It provides help on how to Start-up & shutdown and basic tools that help us use it.
- Mathematics: It provides help on Mathematical operations & data analytics.
- Programming: It provides help in the development of its applications.
- Graphics: Topics related to techniques for plotting, printing, graph annotation and Handle Graphics.
- 3-D Visualization: Provides help on Visualization tools and techniques.
- Creating Graphical User Interfaces: Documents related to GUI-building techniques and writing ‘callback functions’.
- External Interfaces/API: It contains documents related to the Matlab engine, MEX-files, Java interfacing, and the serial port.
Operators Used in Matlab
Below is a list of some commonly used operators which can be used directly to achieve desired results:
4.5 (2,316 ratings)
|*||Matrix and scalar multiplication|
|.*||For multiplication of arrays|
|^||For matrix and scalar exponential calculations|
|.^||For Array exponentiation|
|:||To generate elements with regular spaces|
Matlab System Comprises of 5 Major Parts
Given below are the 5 major parts:
1. Development Environment
It is a set of facilities and tools that help us to use files and functions. Most of these tools are in the form of a graphical user interface. It includes Matlab desktop & Command Window, an editor and debugger, a command history, browsers for help, workspace, search path, and the files.
2. Matlab Mathematical Function Library
It is a collection of computational algorithms ranging from basic functions like sum, multiplication, trigonometric & complex arithmetic, to sophisticated functions like matrix eigenvalues, matrix inverse, Bessel function.
3. Matlab Language
It is a high-level matrix or array language which contains control flow statements, functions, input-output, data structures, and object-oriented programming features. It allows the creation of quick, use and throw programs and also the creation of large, complex application programs.
It provides extensive capabilities for displaying matrices and vectors as graphs. These graphs can also be printed and annotated as per requirement. Graphics include high-level functions for 2D and 3D image processing, data visualization, presentation graphics, and animation. It also includes functions that allow us to fully customize the look and feel of the graphics and also to build full-fledged graphical user interfaces on our Matlab applications.
5. Matlab External Interfaces/API
This library allows us to write Fortran and C programs that have the capability to interact with it. It includes facilities for dynamic linking, i.e. calling routines from Matlab, calling it as a computational engine and for reading & writing of MAT-files.
Local Matlab Environment
Let’s now see how can we set up a Matlab environment in our system. You can download it from the following link:
MathWorks provides 3 versions of Matlab, a trial version a student version and a licensed product. For student or trial version we need to log into their site and then wait for a little to get the approval. Once the software is downloaded, it can be easily installed like any other software.
Once we launch it, we see the main working window which is called Desktop. This desktop appears as the default layout.
The Desktop contains the following panels:
1. Current Folder
This panel is used to view the project files and folders
Here is how ‘Current folder’ looks like:
2. Command Window
This panel is the area where commands are entered in the command line. Command Window is indicated with the help of a command prompt (>>)
Here is a view of ‘Command Window’:
This panel shows the variables which are created or imported from the files.
Below is the view of ‘Workspace’:
4. Command History
It shows and also returns commands that are entered in the command line.
Here is a view:
It behaves as and interpreting the environment. We can give it a command & it will execute it straight away. If we type a simple addition expression like 4 +4, and press enter, it returns answer as 8. Similar is the case for other operators.
This has been a guide to How to Use Matlab? Here we discuss how to use Matlab? 5 major parts of the Matlab System along with the local environment. You may also have a look at the following articles to learn more –