Matlab

Submitted by: Submitted by

Views: 55

Words: 3493

Pages: 14

Category: Other Topics

Date Submitted: 08/10/2014 07:07 AM

Report This Essay

Matlab introduction

* It is an interactive program for numerical computation and data visualization, which along with its programming capabilities provides a very useful tool for almost all areas of science and engineering.

* MATLAB prompt (») will be used to indicate where the commands are entered. Anything you see after this prompt denotes user input (i.e. a command).

* MATLAB is case-sensitive, which means that a + B is not the same as a + b. Different fonts, like the ones you just witnessed, will also be used to simulate the interactive session. This can be seen in the example below:

e.g. MATLAB can work as a calculator. If we ask MATLAB to add two numbers, we get the answer we expect.

» 3 + 4

ans =

7

Command window:- This is a main window which is characterised by the matlab command prompt(<<).when we launch the application program matlab puts us in this window.

Figure window:- The output of a graphic command type occurs in the figure window.

Edit window :-this is where matlab edits,create and save programmes in files called m-files.

Fprintf:-output statement

Matlab Basics

Defining a row vector with components the numbers 1, 2,3, 4, 5 and assigning it a variable name, say x.

» x = [1 2 3 4 5]

x =1 2 3 4 5

Note that we used the equal sign for assigning the variable name x to the vector, brackets to enclose its entries and spaces to separate them. (Just like you would using the linear algebra notation). We could have used commas ( , ) instead of spaces to separate the entries, or even a combination of the two. The use of either spaces or commas is essential!

* To create a column vector (MATLAB distinguishes between row and column vectors, as it should) we can either use semicolons ( ; ) to separate the entries, or first define a row vector and take its transpose to obtain a column vector.

» y = [6;7;8;9;10]

y =

6

7

8

9

10

» y =...