Experiment-1: Date: OBJECTIVE: 1: Creating A One and Two-Dimensional Array (Row / Column Vector)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

EXPERIMENT-1

DATE:
OBJECTIVE: 1: Creating a One and Two-Dimensional Array (Row / Column Vector)
(Matrix of given size) then,
(A) Performing Arithmetic Operations - Addition, Subtraction, Multiplication and
Exponentiation.
(B). Performing Matrix operations - Inverse, Transpose, Rank with plots.
SOFTWARE USED: MATLAB
PROCEDURE:

A=[1 2 3 4]

A=[1 2 3;4 5 6;7 8 9]

B=[3 5 6;6 4 2;2 1 5]

C=A-B

D=A+B

E=A*B

G=A/B

Z=A.*B

W=A./B

Q=A\B

det(A)

det(B)

transpose(A)

transpose(B)

rank(A)

rank(B)

exp(A)

exp(B)
inv(A)

inv(B)

OUTPUT:
A=
123
A=
123
456
789
B=
356
642
215
C=A-B
C=
-2 -3 -3
-2 1 4
574
D=A+B
D=
479
10 9 8
9 9 14
E=A*B
E=

21 16 25

54 46 64

87 76 103

G=A/B

G=
0.4545 -0.0909 0.0909

0.7955 0.2159 0.1591

1.1364 0.5227 0.2273

det(A)

ans =

det(B)

ans =

-88

transpose(A)

ans =

147

258

369

transpose(B)

ans =

362

541

625

rank(A)

ans =

rank(B)

ans =

exp(A)

ans =

1.0e+003 *

0.0027 0.0074 0.0201


0.0546 0.1484 0.4034

1.0966 2.9810 8.1031

exp(B)

ans =

20.0855 148.4132 403.4288

403.4288 54.5982 7.3891

7.3891 2.7183 148.4132

Z=A.*B

Z=

3 10 18

24 20 12

14 8 45

W=A./B

W=

0.3333 0.4000 0.5000

0.6667 1.2500 3.0000

3.5000 8.0000 1.8000

Q=A\B

Q=

1.0e+016 *

3.1525 0.9007 -3.1525

-6.3050 -1.8014 6.3050

3.1525 0.9007 -3.1525

inv(A)

ans =

1.0e+016 *

-0.4504 0.9007 -0.4504

0.9007 -1.8014 0.9007


-0.4504 0.9007 -0.4504

inv(B)

ans =

-0.2045 0.2159 0.1591

0.2955 -0.0341 -0.3409

0.0227 -0.0795 0.2045

SIGNATURE:

Introduction to MATLAB

1.1 Introduction

MATLAB is a high-performance language for technical computing. It


integrates computation, visualization, and programming in an easy-to-use
environment where problems and solutions are expressed in familiar
mathematical notation.
The name MATLAB stands for matrix laboratory. MATLAB was originally
written to provide easy access to matrix.

1-1-1 Starting and Quitting MATLAB


• To start MATLAB, double-click the MATLAB shortcut icon on your
Windows desktop. You will know MALTAB is running when you see the
special " >> " prompt in the MATLAB Command Window.
• To end your MATLAB session, select Exit MATLAB from the File menu in
the desktop, or type quit (or exit) in the Command Window, or with easy way
by click on close button in control box.

1-1-2 Desktop Tools

1- Command Window: Use the Command Window to enter variables and run
functions and M-files.
2- Command History: Statements you enter in the Command Window are
logged in the Command History. In the Command History, you can view
previously run statements, and copy and execute selected statements.
3- Current Directory Browser: MATLAB file operations use the current
directory reference point. Any file you want to run must be in the current
directory or on the search path.
4-Workspace: The MATLAB workspace consists of the set of variables
(named arrays) built up during a MATLAB session and stored in memory.
5- Editor/Debugger Window: Use the Editor/Debugger to create and debug
M-files.

1.2 Basic Commands

• clear Command: Removes all variables from workspace.


• clc Command: Clears the Command window and homes the cursor.
• help Command: help <Topic> displays help about that Topic if it exists.
• lookfor Command: Provides help by searching through all the first lines of
MATLAB help topics and returning those that contains a key word you specify.
• edit Command: enable you to edit (open) any M-file in Editor Window. This
Command doesn’t open built-in function like, sqrt.
• more command: more on enables paging of the output in the MATLAB
Command window, and more off disables paging of the output in the
MATLAB command window.

Notes:

• A semicolon “; "at the end of a MATLAB statement suppresses printing of


results.
• If a statement does not fit on one line, use " . . . ", followed by Enter to
indicate that the statement continues on the next line. For example: >> S=
sqrt (225)*30 /...(20*sqrt (100)
• If we don’t specify an output variable, MATLAB uses the variable ans (short
for answer), to store the last results of a calculation.
• Use Up arrow and Down arrow to edit previous commands you entered in
Command Window.
• Insert “% "before the statement that you want to use it as comment; the
statement will appear in green color.

You might also like