ee computer application

23
EE 512 / EE 512L

Upload: wang-sol

Post on 04-Jun-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 1/23

EE 512 / EE 512L

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 2/23

Variables

Output Format

Character String

Vector O erations

Elementary Matrix Operations

Utility Matrices

Complex Numbers

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 3/23

Abbreviation of MATrix LABoratory

An interactive program for numericalcomputation and data visualization.

It is supported on Unix, Macintosh and

Windows environments. Syntax are similar for DOS version

MATLAB integrates mathematical computing,

visualization, and a powerful language toprovide a flexible environment for technical

computing.

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 4/23

Numeric computation and algorithm

development. Symbolic computation (with the built-in

Symbolic Math functions).

Modeling, simulation and prototyping.Data analysis and signal processing.

Engineering graphics and scientific

visualization.

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 5/23

To start MATLAB click on the MATLAB icon or type

in MATLAB, followed by pressing the enter or return

key at the system prompt. The screen will produce the

MATLAB  prompt >> (or EDU >>), which indicates

that MATLAB is waiting for a command to be entered.

In order to quit MATLAB, type  quit or exit after the

prompt, followed by pressing the enter or return key.

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 6/23

A Command Window which is used to enter 

commands and data to display plots and graphs.

A Graphics Window which is used to display plots and

graphs.

An Edit Window which is used to create and modify

M-files. M-files are files that contain a program or 

script of MATLAB commands.

Help Window provides help information

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 7/23

To type a command the cursor must be placed next to

the command prompt (>>).

Once a command is typed and the   ENTER   key is

 pressed, the command is executed.

Several commands can be type in the same line.

It is not possible to go back to a previous line in thecommand window.

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 8/23

Abort

 In order to abort a command in MATLAB, hold down

the control key and press c to generate a local abort 

with MATLQAAB.

Semicolon(;)

Typing % When per cent symbol (%) is typed in the beginning

of a line, the line is designated as a comment. When

the enter key is pressed, the line is not executed.

 If a semicolon (;) is typed at the end of a command,the output of the command is not displayed.

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 9/23

The clc command

 Typing clc command and pressing enter cleans the

command window. Once the clc command is

executed, a clear window is displayed.

Help

 MATLAB has a host of built-in functions. For a

complete list, refer to MATLAB user’s guide or referto the on-line Help. To obtain help on a particular

topic in the list, e.g., inverse, type help inv.

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 10/23

>> variable = expression

>> A = [1 2 ; 3 4]

The display will be:

4321

= A

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 11/23

Order of Precedence

1st

 parentheses2nd exponentiation

3rd multiplication, division (equal precedence)

4th addition and subtraction

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 12/23

2/87  +>> Type and press ENTER

11

=ans8/2 is executed  first 

2/)87(   +>> Type and press ENTER

5000.7

=ans7+8 is executed  first 

2/3^5>> Type and press ENTER

5000.62

=ans5^3 is executed  first , then /2 is executed next 

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 13/23

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 14/23

Common math functions

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 15/23

Common exponential functions

 

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 16/23

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 17/23

A variable is a name made of a letter or a

combination of several letters and digits. Variable names can be up to 63 (in MATLAB 7)

characters long (31 characters on MATLAB

. .MATLAB is case sensitive. For instance,   XX,

 Xx, xX and xx are the names of four 

different variables.

It should be noted here that not to use the

names of a built-in functions for a variable.

 sin, cos, exp, sqrt , … , etc.

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 18/23

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 19/23

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 20/23

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 21/23

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 22/23

In a right triangle shown a=11cm and c=21cm. Define a and cas variables, then:

a)   Using Pythagorean theorem, calculate b by typing oneline in the command window.

b)   Using b from part a), and the acos(x) function, calculatethe angle in degrees, Φ in degrees, typing in one line inthe command window

;21;11

=>>

=>>

ca a

b

Φ

( )

8885.17

)2^()2^(

=

−=>>

b

ac sqrt b

( )

0195.1

cos

=

=>>

φ 

φ caa

8/13/2019 EE computer application

http://slidepdf.com/reader/full/ee-computer-application 23/23

;18=>>  a

In the triangle shown a=18cm, b=35cm and c=50cm.

Define a,b and c as variables, and then calculate the

angle, ,(in degrees) by substituting the variables in

the law of cosines. β 

 β cos2222 abbac   −+=

;50

;

=>>

=

ca

b

42612

2222^cos

.beta =

*a*b)) )/(--a^ -b^ ((c>> beta=a

( )

0046.139

)/180(*2222cos

beta =

 pi*a*b)) )/(--a^ -b^ ((c^ a>> beta=

 β