matlab

Attribution Non-Commercial (BY-NC)

85 views

matlab

Attribution Non-Commercial (BY-NC)

- VBA
- Range-bound trading continues
- GAS Leakage System
- Automatic Gas Leakage Detection Using Gsm
- Project VBA Project Guru (1)
- Apple vs. FBI Motion to Vacate
- matlab codes
- Solution Ch 05
- Ian Stewart 17 Equations That Changed the World Topten List From Author
- Implied Volatility
- Volatility Calculation
- Philosophical Foundations
- DESIGN AND CONSTRUCT A DUAL BAND MOBILE JAMMER FOR GSM 900 & GSM 1800
- Historical Volatility
- Old-School Theory is a New Force - Bayesian Probability
- vba
- Axioms of Probability a Probability Function p
- matlab
- The Value of Volatility
- Example of Perfect, Beautiful English sentences for Story Writing

You are on page 1of 22

Topics Covered:

1. Introduction.

2. MATLAB windows.

3. Arithmetic operations with scalars.

4. Working in the command window.

5. Defining variables (scalars).

1-4

visualization and programming.

The name MATLAB stands for MATrix LABoratory.

Its basic data element is an array (explained later).

Use it as a calculator.

Define variables and use them in calculations.

Use built-in functions (sin, cos, max, min, etc.).

Plot graphs.

Write and run computer programs.

Do symbolic calculations.

6

MATLAB windows:

MATLAB is started. It has the command prompt ’ » ‘.

All commands can be typed in this window. Used for

running programs written by user.

Figure Window: Contains graphs created by graphics

Editor Window: Used for writing and editing

programs. This window is opened from the File menu

in the Command Window.

Help Window: Contains help information. This

window is opened from the Help menu in any of the

previous windows.

6

(The Command Window opens

Command Window

when MATLAB is started)

Command prompt

7

Figure Window (The Figure Window opens

automatically by the plot command)

7

Editor Window (The Editor Window is opened from the

file menu in the Command Window)

8

Help Window (The Help Window can be opened from the

Help menu of any of MATLAB windows)

8-9

WORKING IN THE COMMAND WINDOW

after the command prompt (>>).

• Once a command is typed, and the “Enter” key is

pressed, the command is executed. (Only the last

command is executed. Everything executed before

is unchanged)

• It is not possible to go back to a previous line and

make a correction.

• A previously typed command can be recalled to

the command prompt with the up-arrow key ( ↑) .

10

ARITHMETIC OPERATIONS WITH SCALARS

Addition + 5+3

Subtraction - 5-3

Multiplication * 5*3

Right Division / 5/3

Left Division \ 5\3=3/5

Exponentiation ^ 5^3

ones. For vectors and matrices the arithmetic operations can

either follows matrix algebra rules, or can be performed on

element-by-element basis (discussed in the next lectures).

10

ORDER Of PRECEDENCE

(The order in which operations are executed by the computer)

precedence operations.

If two operations have the same precedence, then the expression is

executed from left to right.

PRECEDENCE OPERATION

Second Exponentiation.

11

USING MATLAB AS A CALCULATOR

Using numbers:

>> 7+8/2 Type and press Enter 8/2 is executed first

ans =

Computer response

11

ans =

Computer response

7.5000

ans =

Computer response

7.6667

11

5^3/2 Type and press Enter 5^3 is executed first,

ans = /2 is executed next.

Computer response

62.5000>>

ans = ^ is executed next,

Computer response + is executed last.

5

executed first,

ans =

Computer response /3 is executed next,

11 + is executed last.

12-

DISPLAY FORMATS 13

The format command controls how output numbers appear on the

screen. Input numbers can be written in any format.

digits.

format long 41.42857142857143 Fixed-point with 14 decimal

digits.

format short e 4.1429e+001 Scientific notation with 4

decimal digits.

format long e 4.142857142857143e+001 Scientific notation with

15 decimal digits.

Format bank 41.43 Two decimal digits.

13-

15

MATLAB BUILT-IN MATH FUNCTIONS

In addition to arithmetic operations, MATLAB can be used to

calculate elementary math functions. The most common ones are:

cos(x) x in radians log(x) natural logarithm

tan(x) x in radians log10(x) base 10 logarithm

cot(x) x in radians sqrt(x) square root

The inverse is: asin(x), abs(x) absolute value

acos(x), etc.

Examples:

>> >> sqrt(169) >> log10(10000)

sin(0.78539)

ans = ans =

ans =

13 4

MATLAB 0.7071

has hundreds of built-in functions (this will be discussed in

future lectures).

16-

18

THE ASSIGNMENT OPERATOR

OPERATOR.

hand side specific value, or a computable

can only be expression (an expression that

one includes values and/or previously

variable. defined variables).

16-

THE ASSIGNMENT OPERATOR 18

For example, if you type:

>> x = 3

MATLAB assigns the value of 3 to x.

x=

3

If then you type:

>> x = x + MATLAB assigns a new value to x, which

5 is the old value 3 plus 5.

8 meaning since it implies: 0 = 5.)

x + 4 = 30 is not valid. MATLAB does not solve for x,

but the statement:

x = 30 – 4 is valid (the number 26 is assigned to x.)

16-

DEFINING VARIABLES 18

A variable is defined by typing a variable name followed by the

assignment operator (equal sign) and then a value, or a

mathematical expression.

>> a=8 Type and press Enter

a=

Computer response

8

B=

Computer response

12

Once a variable is defined, the computer remembers and stores its

value. The variable can then be used in further calculations.

>> a+B >> a/B >> B/a >> B^a

ans = ans = ans = ans =

20 0.6667 1.5000 429981696

16-

18

Variables can also be used to define new variables

>> d=a*B

d=

96

Once in existence, variables can be used in functions

>> sqrt(d)

ans =

9.7980

A previously defined variable can be redefined and reassigned

a new value.

18

RULES ABOUT VARIABLES NAMES

Variable name can contain letters, digits, and

the underscore character.

Variable name must begin with a letter.

MATLAB is case sensitive; it distinguishes

between uppercase and lowercase letters. For

example, A and a are not the same variable.

18

AVOID USING NAMES OF FUNCTIONS

FOR VARIABLES.

can not be used.

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

OR:

max, min, sum, det, …., etc.

18-

19

PREDEFINED VARIABLES

MATLAB has several variables that are predefined.

These variables can be redefined to have any other value.

It is probably better not to use the predefined variables as

variable names.

Some of the predefined variables are:

inf (infinity)

i (square root of –1) j (square root of –1)

ans (the value of the most recent calculation)

Typing these variables gives:

>> pi >> sin(pi/4) >> eps >> inf >> i

ans = ans = ans = ans = ans =

3.1416 0.7071 2.2204e-016 Inf 0 + 1.0000i

9,

SOME USEFUL COMMANDS 19

When these commands are typed in the Command Window they

either provide information, or perform a task.

; When a semicolon is typed at the end of a line, the

computer does not displays the output.

>> abc=37 >> def=23;

abc = >>

37

clear Removes all variables from memory.

clear x y z Clears only variables x, y and z.

who Lists the variables currently in memory.

clf Clears the Figure Window.

% typing % at the beginning of a line designates the line

as a comment, which is not executed.

- VBAUploaded byVinay Shekar
- Range-bound trading continuesUploaded byTrading Floor
- GAS Leakage SystemUploaded bySirajudheen TP
- Automatic Gas Leakage Detection Using GsmUploaded byKunal Singh
- Project VBA Project Guru (1)Uploaded bypvenky_kkd
- Apple vs. FBI Motion to VacateUploaded byAndy Greenberg
- matlab codesUploaded bySubratKumarKar
- Solution Ch 05Uploaded bySabeen Shuja
- Ian Stewart 17 Equations That Changed the World Topten List From AuthorUploaded byjibaowl
- Implied VolatilityUploaded bybhavnesh_mutha
- Volatility CalculationUploaded byFaisal Koroth
- Philosophical FoundationsUploaded byHannah Faye Valencia
- DESIGN AND CONSTRUCT A DUAL BAND MOBILE JAMMER FOR GSM 900 & GSM 1800Uploaded byAffo Alex
- Historical VolatilityUploaded bybhavnesh_mutha
- Old-School Theory is a New Force - Bayesian ProbabilityUploaded byMahyuddin Husairi
- vbaUploaded byEarnest Reigner Bahian
- Axioms of Probability a Probability Function pUploaded bylocalhost0
- matlabUploaded bySajidh M Shamsudeen
- The Value of VolatilityUploaded bygr8fun5052
- Example of Perfect, Beautiful English sentences for Story WritingUploaded byDinnKotaz
- How to Build Correctly Ordered Sentences in EnglishUploaded byvanvun
- Implied Volatility Report_Group 1Uploaded bySiti Maghfirotul Ulyah
- Volatility Stop SystemUploaded bySimone Mercer-Huggins
- vba sampleUploaded bysaileshbehera
- ENGG953 Spring2016 Lectures Lecture Bayesian Theorem Posterior ProbabilityUploaded byNasir Naeem
- 47442105-Gas-Leakage-Alerting-System-in-IndustriesUploaded byGanesan S BE
- The Motley Fool “Options Edge” HandbookUploaded byapi-25895447
- option StrategiesUploaded byPradeep Singha
- Option MoneyUploaded byATR

- CSE Syllabus-11.06.19.pdfUploaded byAmitendu Mallick
- A Partial List of on-Line Matlab TutorialsUploaded byyashwant1299523
- DspUploaded byjohnsamvlb
- Modeling and Control of an Acrobot Using MATLAB and SimulinkUploaded byridho
- dsp labUploaded byAman Singla
- Computer Aided Simulation LabUploaded bySabareesan Subramanian
- WaferMapperUsersGuide1.0Uploaded byJuan Edo Rodríguez Gatica
- DSP System Toolbox™ Getting Started GuideUploaded byKhai Huynh
- Matlab controls.docUploaded byprajinikanth
- matlab case studyUploaded byrameshramyb
- CSE330_4MatlabFunctions.pdfUploaded byTuệ Nguyễn
- Plotting in MatlabUploaded byariyanamvong8041
- Design At 10gbps Using MATLABUploaded byMatlabAsignmentExperts
- Sim Power SystemsUploaded byPhan Giang Châu
- Matlab Part2 Computing and ProgrammingUploaded byreza rahmad
- Downey 07 Mat LabUploaded bySamuel Dambani
- SturmMATLAB.pdfUploaded byAhmed Al-nasheri
- Basics of ProgrammingUploaded bysetup.143
- Digital Image Correlation _ Tracking With MatlabUploaded byrajibme
- Matlab GUI Solo NumerosUploaded byFreddy Plata Antequera
- visualization and simulation in schedulingUploaded bymac2022
- fnafbjeb2j3b8h23Uploaded byTanonst
- Writing_Fast_Matlab_Code.pdfUploaded byМилан Лукић
- SciLab IntroUploaded bykcshieh
- 46457Uploaded byKhadar Basha
- Octave Programming TutorialUploaded byshafiahmedbd
- qualkitdo_slvnv_tqpUploaded byJanos Kovacs
- matplotlib (1)Uploaded bysamtux
- ncorrmanual_v1_2_1Uploaded byVitor Carneiro
- Book ListUploaded byDeepanshu Lulla