8/2/2019 2-MatlabCharacter
1/3
Characteristics of the MATLAB Environment
MATLAB
originally developed to be a Matrix Laboratory interactive system and programming language for scientific and technical computation writing computer solutions in MATLAB is much quicker than using a high-level language
MATLAB Windows
Prompt To begin, select the MATLAB program from a menu in your operating system or just click
MATLAB icon with mouse.
To exit, use quit orexit.
Display windows Command window: used to enter commands and data and to print results
Graphic window: used to display plots and graphs
Edit window: used to create and modify M-files, which are files that contain a program or
script of MATLAB commands
MATLAB Expo To see some of the capabilities of MATLAB, enter the demo command. This initiates the
MATLAB Expo, a graphical demonstration environment that illustrates some of the
different types of operations. To get help menu, simply enter the help command.
8/2/2019 2-MatlabCharacter
2/3
INITIALIZING MATRICES
Explicit Lists
A = [2.7];
B = [1, 2.7];
C = [-2, 0, 3; 1, 1, 9.2; 0, 0, 2]; or [-2 0 3;1 1 9.2; 0 0 2];
D = [1 2
3 4];
B = [1 2];
S = [3 B] (= [3 1 2])
S(2) = 5 changes the second value in the matrix S from 1 to 5
S(4) = 7.2 makes matrix S having four values instead of threeS(7) = -2 , then the matrix S will have seven values, and the values of S(5) and S(6) are
automatically set to zero
Note: The who command list the matrices that you have defined, and
the whos command list the matrices and their sizes.
Colon Operator
A = [-1 0 0;1 1 2; 0 0 2];x = A(:, 1); the vector x will contains the 1st column of the matrix A
h = 1:8; will generates a vector h that contains the numbers from 1 to 8
time = 0.0:0.5:5.0;
values = 10:-1:0;
C = C_partial_1 = C(:, 2:3) =
200
011
011
001
20
01
01
00
A means the transpose of A
x = 0:4;
y = 5:5:25; [x y] =
254
203
152
101
50
8/2/2019 2-MatlabCharacter
3/3
Special Values and Special Matrices
pi represents
i, j represents 1
Inf represents infinity
zeros; ones; eye; size etc.
A = zeros(3);
B = zeros(3,2);
C = [1 2 3;4 2 5];
D = zeros(size(C));
A =
000
000000
B =
00
0000
C =
524
321D =
000
000
User Input
z = input(Enter values for z in brackets: );