5 views

Uploaded by Rolando Resurreccion

Basic Commands using MATLAB

- Euler s Formula
- Introducing Matlab
- How to Study Math
- MATLAB General
- Study Techniques
- Introducing the Blind Man Technique-Study Less and Retain More
- Studying for Math Tests
- Fact Separations
- Matlab Manual
- Derivative Module 2 September 2011
- STUDY TECHNIQUES
- tmp913C
- All Sheets
- Notes on MATLAB
- 49053182 Matlab Manual
- Assignment 2 A181individual Questions
- CSD Home
- TapBASIC Manual
- Used When You Want to See if It is Equal to Something
- Freefem++Doc

You are on page 1of 8

Display Window

Special/Built-in Variables:

- ans : default variable name for the result

- i / j : imaginary number

- pi : = 3.1415926

- eps : = 2.2204e-016, smallest amount by which 2 numbers can differ

- Inf or inf : , infinity

- NaN or nan : not-a-number

Basic Symbols used in MATLAB:

+ Plus sign. Used in addition.

- Minus sign. Used in subtraction

* Multiplication sign. Used in multiplication

/ Division sign. Used in division

^ Used in exponentiation/power.

= Equal sign. Used to assign values to a variable.

Basic MATLAB commands

clc Clears the command window

clear Clears the workspace (the variables and stored values)

MATLAB is strict about the commands. The commands must be inputted in lowercase.

Trigonometric Functions Inverse Trigonometric Functions

Radians Degrees Radians Degrees

cos(val) cosd(val) acos(val) acosd(val)

sin(val) sind(val) asin(val) asind(val)

tan(val) tand(val) atan(val) atand(val)

cot(val) cotd(val) acot(val) acotd(val)

csc(val) cscd(val) acsc(val) acscd(val)

sec(val) secd(val) asec(val) asecd(val)

Hyperbolic Functions (in Radians) Inverse Hyperbolic Functions (in Radians)

cosh(val) coth(val) acosh(val) acoth(val)

sinh(val) csch(val) asinh(val) acsch(val)

tanh(val) sech(val) atanh(val) asech(val)

Exponential Function Logarithmic Functions

e

x

= exp(x) ln(x) = log(x)

log(x) = log10(x)

Other Functions

X

1/n

= nthroot(X,n)

n

= sqrt(n)

conj(X) Returns the complex conjugate the elements of X

mod(X,Y) Outputs the remainder of X divided by Y

size(matrix) Returns the row size and column size of the matrix

Single Values

Inputting values into a value in a variable is possible with the use of an equal sign:

A=8;

Note: the semicolon (;) is used as a suppressant of the output hence the value is still placed in the

designated variable. Try using commands without the semicolon to see the difference.\

Transferring the value of a variable is also possible in matlab:

B=A;

Array and Matrices

Vector is simply a list of number. Vector is referred to as either column matrix or row matrix

in advance algebra. Square brackets [ ] are used to contain numbers in a variable. White spaces or

comma is used to separate different elements.

The following is a row vector:

matA= [ 1, 2, 3, 4, 5];

In the column vector, a semi-colon is used to separate elements. The semi-colon is

somewhat similar to a carriage return or the enter key in the keyboard whereas the next element will be

placed in the next line.

matB=[10; 9; 8; 7; 6; 5];

Matrix operations are possible in MATLAB. Some of these are addition, subtraction, multiplication, and

many more. The MATLAB considers the rules in matrix operations thus it shows a message whenever

the operation commanded by the used is invalid:

matA+matB - this command will show an error in the operation written in red

matC=[5, 5, 5, 5, 5];

matA+matC

- this command will be executed and the answer will be displayed

in the command window

The transpose of a matrix is possible with the use of the following:

transpose(variable) transposes the matrix stored in the variable

variable

Different sizes of matrices are possible in MATLAB. Comma , is used to separate each column; semi-

colon ; is used to define new row.

matrixA=[1, 2, 3, 4 ; 5, 6, 7, 8 ; 9, 10, 11, 12 ; 1, 6, 5, 3]

Generating matrices using MATLAB functions

There are several built-in functions that can be used to generate matrices. The following are the said

function:

zeros(M,N) MxN matrix of zeros

ones(M,N) MxN matrix of ones

rand(M,N) MxN matrix of uniformly distributed random numbers on (0,1)

eye(M) an identity matrix of size M

Matrix Index

The matrix indices begin from 1 unlike C which is 0. Calling an element in a matrix is possible using the

syntax below:

matrix(row#_position, column#_position)

Given:

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

Z(1, 1) = 1

Z(2, 3) = 6

Z(1, 3) = 3

it gets the complex conjugate of each element in the matrix

then it transposes the matrix (Hermitian transpose)

Note: calling a non-existent index (negative number

or an index exceeding the matrix dimension) will

produce an error.

Concatenation of Matrices

In concatenating matrices, the dimensions must be consistent. In short, concatenating a (2x2) matrix to

a (3x3) matrix is NOT possible. A (2x2) matrix can only be horizontally concatenated with a (2xN) matrix;

a (3x3) matrix can only be vertically concatenated with a (Nx3) matrix and so on and so forth. An error

will occur if the dimension is not consistent.

Example of concatenation:

Range

The symbol used as a range in the colon sign (:). Range is used to easily enumerate elements in a certain

matrix. The colon sign may simply be read as to.

A = [1 2 3 4 5 6 7 8 9 10]; is the same as A = 1:10

B = [1 2 3 4 5; 6 7 8 9 10]; is the same as B = [1:5 ; 6:10]

Note: The default increment of the colon sign is 1. The increment value can be changed by using the

following syntax:

Starting_number : increment_value: Ending_number

C = [1 , 1.5 , 2 , 2.5 , 3 , 3.5]; is the same as C = 1 : 0.5 : 3.5

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

rowone = [ D(1,1), D(1,2), D(1,3)] is the same as rowone = D(1 , : )

columntwo = [ D(1,2), D(2,2), D(3,2)] is the same as columntwo = D(: , 2)

Dot Operators

.* element-by-element multiplication

./ element-by-element division

.^ element-by-element power

Example

Plotting Functions

plot(x , y)

Example:

stem(x , y)

Example:

subplot(row,column,position)

Example:

hold on

Example:

- Euler s FormulaUploaded bybauemmvss
- Introducing MatlabUploaded byadnan
- How to Study MathUploaded byMuhammad Turawa
- MATLAB GeneralUploaded byArt Mendoza
- Study TechniquesUploaded byChinmoy Talukdar
- Introducing the Blind Man Technique-Study Less and Retain MoreUploaded byskycall28
- Studying for Math TestsUploaded byMs. Cookie
- Fact SeparationsUploaded byDigi-Block
- Matlab ManualUploaded bysapperdeflap
- Derivative Module 2 September 2011Uploaded bypirawin92
- STUDY TECHNIQUESUploaded byBettina Martin
- tmp913CUploaded byFrontiers
- All SheetsUploaded byKarmela Malinao
- Notes on MATLABUploaded bySVR07
- 49053182 Matlab ManualUploaded byElvis Ramos Callupe
- Assignment 2 A181individual QuestionsUploaded bysrhysff
- CSD HomeUploaded by1985 production
- TapBASIC ManualUploaded bymarovada
- Used When You Want to See if It is Equal to SomethingUploaded byPouria Hosseini
- Freefem++DocUploaded byMartino Ermacora
- Assemble Element Stiffness MatricesUploaded byAndy Vallee
- 3Uploaded bythanhthoakt
- lap2_2015Uploaded byyaser
- Class XII Computer HHWUploaded byHarshit Jain
- Transmission Line Modeling 2Uploaded byFengxing Zhu
- Mathematical Model and Six-Degree-Of-Freedom Simulation of Two Business Jet AircraftUploaded byKishan Chowhan

- Datacolor TOOLS User GuideUploaded byxensakata
- Electronic Materials - Problem sheet solution.pdfUploaded byJamie Nguyen
- Modeling and Simulation of Electrical Prevention SystemUploaded byzaizam
- Adam Kemp CV.pdfUploaded byAnonymous vKhqF7S
- CORBA Networking With JavaUploaded bybharatvamsi
- Batching plant.pdfUploaded byskb25
- Chapter2-100ADSUploaded byravi010582
- Cybercrime Prevention Act.pdfUploaded byMarjelLaygo
- 0478_s15_qp_11_2Uploaded bymastermido524
- Working With 3D Objects and Transparencies to Make a Vector Cola Bottle DesignUploaded byAbdul Aziz
- Thermo Scientific THERMOSTATS Brochure.pdfUploaded byJC Aleman
- Fellow Humans America Taken Over by Storm and Football.pdfUploaded byJusticeForEarth
- problem_1-4Uploaded byAnonymous xIzzEifjP
- Mass-10_14_1_-May-2016Uploaded byianfld
- DS1410EUploaded bySprite_tm
- 01214831Uploaded byalansi92004
- Gsm Msg Opcode DetailsUploaded byRajan Kutti
- Panasonic X500Uploaded bykor_m8
- Assignment Computer PlatformsUploaded byhassan_401651634
- srdmanualUploaded byapi-264268525
- dingoo juegosUploaded bygrodeslin
- HP Colour LaserJet Fading FixUploaded byjgreene9951
- Quantum ComputerUploaded byapi-3853034
- victron_energy_off-grid_back-up_islandsystems_eng.pdfUploaded byMikela Ljermontova
- DIS_ch_11.pptxUploaded byVictoria Liendo
- Intake 34 ERP SAP Functional Track (1)Uploaded byAhmed Ali
- ACJC JC 2 H2 Maths 2011 Year End Exam Question Paper 2Uploaded byDKFB
- Sappress Database Admin With OracleUploaded byJagroopSinghBalhra
- Attestation ofattes Documents - Non SaudiUploaded byMuhammad Mustafa
- Educational Facilities CompilationUploaded bymary grace