1 views

Uploaded by Lasitha Perera

MATLABacademy

- Jeff Gill-Essential Mathematics for Political and Social Research (Analytical Methods for Social Research) (2006)
- Matrix Indexing in MATLAB
- MATLAB_session_1.ppt
- Lab 2
- Introduction to Matlab - Image Processing By Dhananjay K. Theckedath
- matlab
- Matlab Tutorial 1
- R Introduction
- Peter Adler r Cheat Sheet
- Matlab Review
- Matlab Tutorial
- MATLAB[unit01].pdf
- Matlab Lab 1
- Computer Aided Simulation Lab
- Matlab Tricks for Vectors
- Rau, R. (2005) - Introducing R to Demographers with applications for Survival Analysis
- 2.6
- An Introduction to R
- Civil Engineering 2008.pdf
- Digital Signal Processing with Applications

You are on page 1of 9

...

When entered x=3+4, MATLAB first evaluates 3+4, then assigns the result 7 to variable X

...

Workspace window (on the right) shows all the variables currently in the workspace

...

Adding a semicolon to the end of a command will suppress the output ( though the comman

will still be executed) as you can see in the Workspace.

When entered a command without a semicolon at the end MATLAB displays the result in the

command window.

...

...

When you enter just a variable name at the command prompt, MATLAB returns the current

value of that variable

...

You can name your MATLAB variables anything you’d like as long as they start with a

letter and contain only letters, numbers, and underscores ( _ ).

...

Command ‘ clear’ can clear all variables (look at the WORKSPACE window to see the

change while entering the command clear)

...

...

pi represents 𝜋

(although four decimal places are shown, it is calculated for more precision internally)

...

notation.

e.g:

>> x=pi/2

x=1.5708

y=sin(x)

y=1

...

3.1 Manually Entering Arrays

...

You can create arrays with multiple elements using square brackets

e.g.

>> x= [3 5]

x= 3 5

...

When you separate numbers by spaces (or commas) MATLAB combines the numbers into a

row vector (an array with one and multiple columns [(1-by –n), here 1 is the #of rows and n is

the #of columns]).

When you separate them by semicolons, MATLAB creates a column vector (n-by-1)

>> x= [7;9]

x=7

...

You can combine spaces and semicolons to create matrices (arrays with multiple rows and

columns)

>> x= [3 4 5; 6 7 8]

x=345

678

...

>>x=[abs(-4) 4^2]

x=4 16

...

first:last

e.g.

>> y=5:8

y=5 6 7 8

...

e.g.

>> x=20:2:26

x=20 22 24 26

...

If you know the number of elements you want in a vector (instead of the spacing between

each element), you could instead use the

It will randomly create a vector with the number of elements you inserted which start and end

at the requested first and last number. Here the space between two consecutive numbers will

be automatically decided.

Note the use of commas (,) to separate inputs to the linspace function

>> x=linspace(0,1, 5)

...

However, you can convert a row vector into a column vector using the transport operator

(’)

>> x=1:3;

>> x=x’

x=1

...

You can create column vectors in a single command by creating the row vector and

transporting it all on one line.

>> x=(1:2:5)’

x=1

5

...

MATLAB contains many functions that help you to create commonly used matrices, such as

matrices of random numbers

Note that the 2 in the command rand(2) specifies that the output will be a 2-by-2 matrix of

random numbers

...

zeros ( , )

4.1 Saving and Loading Variables

You can save variables in your WORKSPACE to a MATLAB specific file format called

MAT-file using save command

...

You can load variables from a MAT-file using the load command

...

5.0 Import Tool

Data stored in a text file can be imported to MATLAB WORKSPACE by selecting that file

in current folder, right click select import data

Any missing data in the text file is highlighted in orange and labelled as NaN which stands

for Not a Number

You can chose how to import data, for example as a single metrix

...

...

You can extract values form an array using row , column indexing

>> x=A(5,7)

Extracts the value in 5th row and 7th column of A and assigns the result to the variable x

...

Use MATLAB keyword end as either a row or column index to reference the last element

>> x=A(end, 2)

Value stored in the last row-1st and last column-2nd place of the A matrix/array is extracted

...

- Jeff Gill-Essential Mathematics for Political and Social Research (Analytical Methods for Social Research) (2006)Uploaded byMarcello Sena
- Matrix Indexing in MATLABUploaded byAkash Ramann
- MATLAB_session_1.pptUploaded byndsram
- Lab 2Uploaded bygeoaamer
- Introduction to Matlab - Image Processing By Dhananjay K. TheckedathUploaded byapi-3768869
- matlabUploaded byOmar Ezzat
- Matlab Tutorial 1Uploaded byAndre Sufadia Simorangkir
- R IntroductionUploaded bySafont Rodrigo Carles
- Peter Adler r Cheat SheetUploaded byhelloapurba
- Matlab ReviewUploaded bygnklol3
- Matlab TutorialUploaded bymysteriosan454
- MATLAB[unit01].pdfUploaded byArmil Senope Monsura
- Matlab Lab 1Uploaded byadane21
- Computer Aided Simulation LabUploaded bySabareesan Subramanian
- Matlab Tricks for VectorsUploaded byksjoseph
- Rau, R. (2005) - Introducing R to Demographers with applications for Survival AnalysisUploaded byjuef42
- 2.6Uploaded byViorel Botnari
- An Introduction to RUploaded byAnastasia Ionas
- Civil Engineering 2008.pdfUploaded byTaimurK99
- Digital Signal Processing with ApplicationsUploaded bysahar
- 102 Syl l 0607 SpringUploaded byErwin Huberto Callang Rivera
- ch05-IPC.pdfUploaded byJoão Henrique Moreira Santos
- Array_LabUploaded byMuhd Danish
- Structural Analysis Lecture No.1Uploaded by2010civ164
- Presentation Optimization 2-LibreUploaded byNhan Tran
- New Text DocumentUploaded byAhmad
- MATLABUploaded byPavan Kumar
- Matlab GraphicsUploaded byJimy Gustavo Vivanco Càrdenas
- Algebra of Random ArraysUploaded byHugo Hernández
- lkUploaded by53melmel

- ImplementationStrategy-IIOE-2-4Dec-2015.pdfUploaded byLasitha Perera
- ImplementationStrategy-IIOE-2-4Dec-2015.pdfUploaded byLasitha Perera
- Principle Component AnalysisUploaded bymatthewriley123
- Matalab Practice 01Uploaded byLasitha Perera
- Chu2015 Absolute Geostrophic Velocity Inverted From World Ocean AtlasUploaded byLasitha Perera
- lokopakarayaUploaded byLasitha Perera
- VShankar Stability IntroUploaded byAndrea Cn

- Physics IsmUploaded byKrishnaah Smuglerzz
- 0610206v3.pdfUploaded byahmed3423
- Thomas Finney - Chapter 13 (www.myUET.net.tc).pdfUploaded bykamilbisma
- Unguru State of the Art ISIS 1979Uploaded byMichael N. Fried
- Industrialization in 15 District - PCAUploaded bySalam Daeng Bengo
- 12 Std Business Math Formulae 1Uploaded bySeshanRamanujam
- Repeated Root and Common Root solution.pdfUploaded byChai Usajai Usajai
- Principles of Applied Math (Math 641).pdfUploaded byLauren Snider
- DisplacementsUploaded byElizabeth Santiago
- GATE Maths Qs All Branch MondalUploaded byNishankzatt
- Comm ViewsUploaded byhappymark2
- Chap 7 The Parabola.pdfUploaded byArah
- Paul E. Gunnells- Weyl group multiple Dirichlet seriesUploaded byHemAO1
- F1DB5d01Uploaded byRauf Khan Rind
- MATLAB - Modelling in Time Domain - Norman NiseUploaded byichigo325
- HSSS Model Paper IIUploaded byabi
- Diff Equation 4 2011 Fall HIGH Order TheoryUploaded byAnna Cristache
- 38 MathematicsUploaded byShivam
- Math 106 Exer13Uploaded byAlex Pumnea
- f -DERIVATIONS ON BP-ALGEBRASUploaded byJASH MATHEW
- 237417099-MODI-Method-Examples-Transportation-Problem.pdfUploaded bysukhdev thakur
- 5-yr_imd_matUploaded byAnonymous gUjimJK
- JSU paper 1-Form 1Uploaded bysurayaothman
- Imo 2010 Official SolutionsUploaded byrysanal
- Review of VectorsUploaded byhaalefom
- Intermediate Algebra Learning TargetsUploaded byhasenbaj
- The Routh Stability CriterionUploaded byPrabhakar Das
- SLP.pdfUploaded bySamima Sabnam
- Software for Algebraic GeometryUploaded byJustin Carden
- EE325 Probability and Random ProcessesUploaded byankit bansal