3 views

Uploaded by Marco Antonio Osorio Clemente

EDICION DE MATLAB EN INGENIERIA CIVIL

EDICION DE MATLAB EN INGENIERIA CIVIL

© All Rights Reserved

- Essential Mathematical Skills (Iqbalkalmati.blogspot.com)
- matlab rref
- Matlab Cheat Sheet
- 1LabExercise.docedited
- A Matlab® Program for Soil Classification Using Aashto Classification
- a
- Introduction MATLAB
- 02 the R Language Part 1
- lecture_13_Matlab_Octave_FreeMat_pt1.ppt
- sj
- Scientific Computing
- Ann Tutorial
- Front Page
- Sample Question Paper Mathematics
- Brochure COEP Oct 12
- 08 MATLAB
- Matlab Basics SENSE
- IntroductiontoMatrixLaboratory (1)
- 1-s2.0-S2212670814000633-main
- MATLAB

You are on page 1of 20

Irfan Turk

Fatih University, 2013-14

What is MATLAB?

MATLAB stands for MATrix LABoratory.

MATLAB is a high-performance language for technical

computing.

Math , computation, and numerical calculations

Algorithm development

Data acquisition

Modeling, simulation, and prototyping

Data analysis, exploration, and visualization

Scientific and engineering graphics

Application development, including graphical user interface

building

Many toolboxes for different applications

MATLAB ENVIRONMENT

Command Window

Type commands

Current Directory

View folders and m-files

Workspace

View program variables

Command History

View past commands

Editor

Writing the code

Variables & Arrays

Variables :

int b;

No need for types, and pre-defining. double a;

float c;

Variable names must begin with a letter, followed by any

combination of letters, numbers and the underscore (_)

character Example:

>>1B=1;

>>_A1=-8;

All variables are created with double precision(as matrices)

unless specified.

Example:

>>x=1;

>>x1=-8;

Above, the variables are 1x1 matrices with double precision

Variables & Arrays

Arrays :

An array consisting of one element is called a scalar. i.e. A=4.

When B=[1, 2, 3], then B is an array of numbers.

Scalars are also treated as arrays by MATLAB (1 row and 1 column).

Row and column indices of an array start from 1.(not zero as in C,

or in others.

Arrays can be classified as vectors and matrices.

Row 1

Row 2

Row 3

array(2,4)

Row 4

Variables & Arrays

Arrays :

i.e. A=4. When B=[1, 2, 3], then B is an array of

numbers.

Scalars are also treated as arrays by MATLAB (1 row

and 1 column).

Row and column indices of an array start from 1.(not

zero as in C, or in others.

Arrays can be classified as vectors and matrices.

Vector and Matrix

Vector: Array with one dimension

C=[1 2 3 4] 1x4 array 4 elements, row vector

1

B= 3 3x1 array 3 elements, column vector

5

Matrix: Array with more than one dimension

1 2

3 4 3x2 matrix 6 elements

A=

5 6

A(3,2)=6 B(3)=5 C(2)=2

Row # Column #

Practice Exercise 2.1

Type the following expressions into MATLAB at the

command prompt, and observe the results:

5+2

5*2

3+2*(4+3)

2.54*8/2.6

6.3-2.1045

3.6^2

1+2^2

sqrt(5)

cos(pi)

Practice Exercise 2.2

Which of the following names are allowed in MATLAB? Make your

predictions, then test them with the isvarname, iskeyword, and which

commands.

1. test

2. Test

3. if

4. my-book

5. my_book

6. Thisisoneeverylongnamebutisitstillallowed?

7. 1stgroup

8. group_1

9. zzaAbc

10. 34wAwy?12#

11. sin

12. log

Operators

+ addition a+b

- subtraction a-b

* multiplication a*b

/ division a/b

^ power a^b

complex conjugate transpose a (apostrophe)

Examples:

Example 1: For a given A(3by3), and B(3by3) matrices,

find A+B, A-B, A*B, B*A,A, B, A^2, and B^2

Example 2:

2*x+3*y+4*z=-2,

4*x -y+ z= 3,

-3*x +3*y+ z=-4

Write the above system by using matrices and find

unkowns (x,y,z)

Operators(Element by element)

.* multiplication a .* b

./ division a ./ b

.^power a .^ b

B.^2, A./B, and B./A. What are the differences between

the calculations A.*B and A.*B, A^2 and A.^2, A/B and

A./B?

Examples

A = [1 2 3; 4 5 6; 7 8 9] Example 4: For a given A on the

A=

1 2 3 left, do the same or similar

4 5 6 operations as below.

7 8 9

x= y= b= c= d=

1 2 3 7 8 9 7 16 27 0.14 0.25 0.33 1 4 9

Examples

Example 5(in book, it is Example 2.1-2nd question):

Volume V=1000

Temperature T=300

Pressure P=100

Molecular weight MW=29

Gas Constant R=8.314

What is mass=m=? Solve it in Matlab

(PV=nRT, and n=m/MW)

Numeric Display Formats

Matlab Command Display Example

2 decimal digits only real values are

format bank displayed 3.14

4 decimal digits engineering

format short eng notation(rounding) 3.1235e+00

14 decimal digits engineering

format long eng notation(rounding) 3.12345678901234e+000

+,-,blank (for positive, negative and

format + zero numbers) +/-/

Saving Your Work

diary on / diary(filename) saves your work in the

fine name specified

save <filename> preserves your variables

load <filename> brings your data back, after clearing

whos command shows your variables again

Script M-Files

Using command window is an easy tool for

calculations. But once you close the Matlab, you loose

the calculations if you do not use the extra commands

explained above.

To overcome this issue, it is better to write the codes in

an M file. In this case, your work will be saved as an M

file into the directory you work.

Example

Example:6 (problem 2.20 from the book)

Create a matrix A equal to [-1/3,0,1/3,2/3], and use each

of the built-in format options below to display the

results:

format short (default format)

format long

format short e

format rat

format short g

Example

Example 7:

X=linspace(0,pi,100) % X is a vector

Y=sin(X) % Y is a vector

plot(X,Y)

title(Plotting)

xlabel(This is x label)

ylabel(This is y label)

Example

Example 8: Plot the graphs below.

a) 0x 2*pi, 1+cos(x)

b) -2*pix pi, sin(x)-1

c) -4x 4, x^2-4

- Essential Mathematical Skills (Iqbalkalmati.blogspot.com)Uploaded byMuhammad Iqbal
- matlab rrefUploaded byandresfelipeguerrero
- Matlab Cheat SheetUploaded byHafeth Dawbaa
- 1LabExercise.doceditedUploaded byroxette
- A Matlab® Program for Soil Classification Using Aashto ClassificationUploaded byIOSRjournal
- aUploaded byJessica Lewis
- Introduction MATLABUploaded byRubina Hannure
- 02 the R Language Part 1Uploaded bymhafod
- lecture_13_Matlab_Octave_FreeMat_pt1.pptUploaded bynavinars
- sjUploaded byTri Kasihno
- Scientific ComputingUploaded byisla
- Ann TutorialUploaded byLuis Oliveira Silva
- Front PageUploaded byAnonymous xyDZ8CtA
- Sample Question Paper MathematicsUploaded byashwani_scribd
- Brochure COEP Oct 12Uploaded byJoseCastilho
- 08 MATLABUploaded byCarlos Fuentes
- Matlab Basics SENSEUploaded byAnonymous 5xfXLt
- IntroductiontoMatrixLaboratory (1)Uploaded bySheeraz Memon
- 1-s2.0-S2212670814000633-mainUploaded byKuber Bogati
- MATLABUploaded bytinkusk24
- Pemrograman Komputer - 03 MatlabUploaded byIgn DiMer
- matlabFMUploaded bySarthak Sourav
- hw#4Uploaded byRalph Bryell Olaso
- Dbms c LabUploaded byNaveen Nagalingam
- CPET190_Lect1Uploaded byLayl Zan
- DocumentUploaded bybialla
- productFlyer_978-0-387-78356-7Uploaded bybrenda
- Matlab PrimerUploaded byJairo Martínez Escobar
- dat structUploaded byBrian Kim
- Median SCL CodeUploaded byBassel Almouie

- Lec 1 -2 IntroductionUploaded byarafatasghar
- MatlabCC++Compiler4Uploaded byAnonymous sAmJfcV
- Ahmed Yosri's CVUploaded byAhmed Yossre
- Exp.1 - Matlab BasicsUploaded byali,r98
- Fundamentals of Matlab FinalUploaded bythamaraikannan
- (Signal Analysis Using MATLAB)Uploaded byRajiv Shah
- Matlab Help_ m FilesUploaded byGiaanNguyen
- Manual Intruction of SIDPAC (NASA Langley)Uploaded byThanh Trường Nhữ
- Tutorial-Time Series Hyperspectral Image AnalysisUploaded byhmenezv
- MatlabUploaded byErik Lerin
- Matlab, UNIX Running on BgUploaded byroitnedurp
- Pinky_eda Lab ManualUploaded byAthiraRemesh
- Matlab Brief GuideUploaded byPrateek Thakur
- IJEAS0210020Uploaded byerpublication
- cps330gUploaded byHoracio Ramos
- ReactLab Kinetics ManualUploaded byFranklinCovey Southasia
- inteco1Uploaded byeto 03
- kalibondUploaded byAjay Kumar Viswanatha
- Lecture 1Uploaded byNikhil Agarwal
- Uses and Abuses of EIDORS - An Extensible Software Base for EITUploaded bysastrakusumawijaya
- Python ScientificUploaded bypramod_vanam
- Vikram Mutneja (316049619)Uploaded byMadalina Mirela Bivolaru
- 2008_REU_UGVUploaded byMuhammad Farhan
- fuzzy and nural approaches in engineering matlab supplimentUploaded byKirtesh Tiwari
- uitableUploaded byIrene Anagua
- 2009b Borrowing Product LicensesUploaded byChristoph Klas
- 3PRR Planar Parallel Manipulator AnalysisUploaded bymail2priyanshu8428
- 1-Image Forgery Detection - Final ReportUploaded byAli Maarouf
- Discussion for ProgrammingUploaded byDevbrat Singh
- Mantenimiento Predictivo MATLABUploaded byJhordan Smith