Getting started with MATLAB, How to create your first MATLAB project?

The name MATLAB stands for MATrix LABoratory, is the fourth generation programming language, and it is developed by Mathworks Inc., USA. MATLAB is great for doing array manipulation, doing specialized math functions, and for creating nice plots quick. It is a Matrix based powerful software package for Scientific, Engineering numerical computation and visualization. Symbolic computation is one of the features that make MATLAB interesting to work with,
apart from the numerous libraries. I also used it for numerical analysis, and in signal processing modeling with SIMULINK.
Complex numerical problems can be solved in fractions of time that required with other high level languages. MATLAB provide an interactive environment with thousands of built in functions; User can create his own functions too. MATLAB program and script files always have filenames ending with ‘.m’; the programming language is exceptionally straightforward since almost every data object is assumed to be an array. Graphical output is available to supplement numerical results.
In 2004, MATLAB had around one million users across the world. MATLAB is widely used in academic and research institutions as well as industrial enterprises.
All commands and the ready to run program file name can be typed in the command window to execute them. Figure window gives the display of the figures as the result of program.

GUI of MATLAB (Different windows in MATLAB)

Command Window
User can enter MATLAB codes in command window. MATLAB is an Interpreter since it executes line by line manner. Once entered, the code will execute at the next moment itself.
Work Space Window
Work Space window contain the current variables used in the program.
Command History Window
Command History Window contain previous executed program. User can refer this field for analyzing previous codes

How to enter a Matrix in MATLAB?

Let we define a matrix as A=[1 2 3;4 5 6;7 8 9]
Command window for the above code is shown in the image

Creating script‘.m’ file

In order to write program as whole, we can create ‘.m’ files. The codes inside an ‘.m’ file can be executed simultaneously.
To create a new file, go File-> New-> Script or press Cntrl+N. Then write your MATLAB code in the new editor.

Commenting and Uncommenting

You can mask some codes from execution of the program. Select the code that you want to mask, then right click on the codes and select ‘Comment’. Then a ‘%’ will appear before each line of codes, that lines are masked while executing the program. To expose masked codes, select the codes and right click then ‘Uncomment’. After doing so the ‘%’ symbol is disappeared from the editor.


Labeling the codes

To label a specific code you can use ‘%’ symbol. The text coming immediately after ‘%’ will not execute. It is also a kind of masking as explained earlier.

Executing editor window codes in MATLAB

To execute the codes written in MATLAB, Select all, right click, then select 'Evaluate Selection'
Then the whole codes executed in the MATLAB platform

Ads


0 comments:

Post a Comment

 

Copyright © 2011 CircuitsGallery| ToS | Privacy Policy |

Contact Us | Write For Us | Advertise on Circuits Gallery | About Us