0 views

Uploaded by Learner eagle

Matlab commands

- Lab 1
- 4114 Modelling and Optimization of Biomass Based Energy Production
- R Tips
- Matrix
- Add Maths Year 10
- PDF MATLAB
- Matlab Worksheet 1
- AIRCRAFT IN THE TRANSONIC VELOCITY RANGE.pdf
- Final PPT-Matrices & Its Applications_presentation
- Art. WF Assad - A Flexible Software Tool for Temporally-precise Behavioral Control in Matlab
- 1.pdf
- DSP--LAB#01
- 06 Mathematics.pdf
- Computer Concepts C Programming June 2012
- Matllab Tut
- ELCE402 Lab Exp00
- Algebra-Lineal-Quiz-2-Semana-6.pdf
- Matlab_tutorial_rapido.pdf
- ME201_Week1
- Week0

You are on page 1of 11

EXPERIMENT : 03

NO

: USAGE OF SOME BASIC

OPERATIONS

DATE OF

: ______________

EXPERIMENT

GROUP NO : ______________

BATCH : ______________

_______________________

_______________________

_______________________

GROUP

: _______________________

MEMBERS

_______________________

_______________________

________________________________________________________________________

_________________________________________________________________________

CONTENTS

PURPOSE .......................................................................................................................... 3

INTRODUCTION............................................................................................................. 3

BASIC OPERATIONS ..................................................................................................... 4

TASK................................................................................................................................ 10

________________________________________________________________________

_________________________________________________________________________

PURPOSE

The purpose of this experiment is to give students the introduction to MATLAB, and a

know how about some commonly used MATLAB commands.

INTRODUCTION

MATLAB is an interactive package for numerical analysis, matrix computation, control

system design and linear system analysis and design. The name MATLAB stands for

matrix laboratory. MATLAB is a high performance language for technical computing. It

integrates computation, visualization, and programming in an easy to use environment

where problems and solutions are expressed in familiar mathematical notation. Typical

uses include:

• Algorithm development

• Modeling, simulation and prototyping

• Data analysis, exploration and visualization

• Scientific and engineering graphics

• Application development, including graphical user interface building

Working in MATLAB

While working with MATLAB you get on your screen always a prompt. This is >>.

This means that MATLAB is ready to accept commands. If you press the enter key, the

commands get executed. Unless you finish your command with a semicolon (; ),

MATLAB displays the result on screen.

With clear you de-allocate memory space for those variables.

________________________________________________________________________

_________________________________________________________________________

BASIC OPERATIONS

Array

Consider an array ‘u’ of numbers as given below

𝑢 = 0 1 2 3 4 5 6 7 8 9 10

1st Method

In this method, all the numbers are separately written in MATLAB

2nd Method

In this method the command is written in such a manner that MATLAB automatically

defines the array with an interval of 1 between the 1st and the last number. However for

this method to work, the array should be in ascending order.

3rd Method

In this method the user specifies the 1st and the last number of the array and the interval

between two consecutive numbers of the array. However for this method to work, the array

should be in ascending order. For the array under consideration the interval required is ‘1’.

________________________________________________________________________

_________________________________________________________________________

Matrix

Let ‘A’ and ‘B’ be two matrices,

1 5 10 2 3

𝐴 = [2 3 7 ] 𝐵 = [5 4]

6 1 1 6 8

To compute the size of any matrix the command size is used. For example, we want to

find the size of B matrix.

________________________________________________________________________

_________________________________________________________________________

Two matrices can be easily multiplied in MATLAB. However, the number of columns

in the 1st matrix should be equal to the number of rows in the 2nd matrix.

Any row or column or a single element of a matrix can be extracted using MATLAB

command. Suppose we want to extract the 1st and 2nd row of matrix A.

Similarly, if you want to extract the 2nd element (column) in the 3st row of matrix A.

Matrix equation can also be solved using MATLAB. Suppose that we want to solve the

system 𝐴𝑥 = 𝐵.

This can be written as:

𝑥 = 𝐴−1 𝐵

In MATLAB, this can be written as:

________________________________________________________________________

_________________________________________________________________________

Plotting

Plotting a graph between two variables can be done in different ways depending on how

the variables are linked.

1st Case (Data Points)

As an example, consider the variation of Coefficient of lift of an airfoil with angle of

attack, such that you have the values of the coefficient of lift at each angle of attack.

To plot the graph between the two variables, Angle of Attack Coefficient of

both the variables will be entered in MATLAB (deg) lift

as separate arrays and using the ‘plot’ 0 0

command, their graph would be plotted. To add 5 0.5

labels to the x-axis and y-axis respectively, the 10 1

commands ‘xlabel’ and ‘ylabel’ would be used 15 1.5

respectively. And to give a title the command 17 1.6

‘title’ would be used. The whole syntax is 18 1.55

given below. 19 1.5

Let’s consider a more complex case. For example you have the lift curve data for

another airfoil shown below and you want to compare both the curves on one graph.

Angle of Attack

Coefficient of lift

(deg)

0 0

4 0.5

8 1.1

12 1.55

16 1.6

17 1.55

18 1.5

For this you will have to create two more arrays, with different names. The complete code

would be:

________________________________________________________________________

_________________________________________________________________________

In the above code, first of all, the values of angles of attack and coefficients of lift for both

airfoils are entered. Then plot command is used. Firstly, the x and y variables of the first

airfoil are called. The term ‘g- -‘gives the first curve green color and a dashed line style.

‘g’ is used to give the green color and ‘- -‘ is used to give a dashed line style. Then the x

and y variables of the second airfoil are called. The term ‘r’ gives red color to the second

curve. The term ‘linewidth’,2 is used to give both the curves a width of 2 units (default line

width is 1 unit). The term … is used, so that by pressing enter, the command is not executed

and you can continue the same command in the next line. Then using xlabel, and ylabel,

labels are given to both axis. To turn the grid on, grid is used. A title can be given using

title. If there are two curves, then it is necessary that each one is identified properly. So for

identification of curves legend is used. Finally to give a specific font size to the labels and

axis, set is used. After pressing enter, the following graph then appears.

________________________________________________________________________

_________________________________________________________________________

If for instance, you have already plotted 1 curve on a figure and without writing a new code

you want to add a new curve to the same plot, then the ‘hold on’ command is used. The

code for this case would be:

If you have plotted one graph and want to plot another graph in a separate window, then

by default if you just use the plot command, MATLAB would overwrite the existing graph

but this not what you want. So for this, figure() is used. This would open both curves in

separate figures.

If the variables are linked through an equation and you are to plot a graph between the two

variables, then one variable is defined as an array and the second variable is given as a

function of the first variable. As an example consider the variation of temperature within

the troposphere. We know that temperature decreases at a constant rate of 6.5ᵒC/1000 m.

So the equation becomes

6.5ℎ(𝑚)

𝑇 = 𝑇0 −

1000

Where 𝑇0 is sea level temperature and 0 < ℎ(𝑚) < 11000 𝑚. If for instance 𝑇0 = 15ᵒ𝐶 .

The the equation would be:

6.5ℎ(𝑚)

𝑇 = 15 −

1000

________________________________________________________________________

_________________________________________________________________________

Note that the commands such as figure(), hold on and other commands that were used in

the 1st case can be used here as well.

TASK

Q1 Define Following Matrices

________________________________________________________________________

_________________________________________________________________________

−1 −12 1.2 5 −1

𝑨 = 2.7 1 −2 4 𝐵 = 2.5

6.6 4.51 0 1 4.8

[−3 −2.2 1 6] [1.6]

a. Compute is size of A

b. Compute AB

c. Extract the elements of A that are in 2nd to 4th row and 1st & 3rd Columns

d. Solve Ax = B for 𝑥.

Q2

𝑧 = 𝑒 −2𝑡 cos(3𝑡 + 1) − 𝜋 ≤ 𝑡 ≤ 5𝜋

b. The deflection of a cantilever beam is the distance its end moves in response to a force applied

at the end. The following table gives the deflection 𝑥 that was produced in a particular beam

by the given applied force 𝑓. Plot the graph:

Force 𝑓 (pound) 0 100 200 300 400 500 600 700 800

Deflection 𝑥 (inches) 0 0.09 0.18 0.28 0.37 0.46 0.55 0.65 0.74

________________________________________________________________________

- Lab 1Uploaded byDeepak Mishra
- 4114 Modelling and Optimization of Biomass Based Energy ProductionUploaded byAnonymous lmCR3SkPrK
- R TipsUploaded byPradeepkumar Muthu
- MatrixUploaded byBeatrizAL
- Add Maths Year 10Uploaded byYenny Tiga
- PDF MATLABUploaded byMuhammad Fauzan Azima
- Matlab Worksheet 1Uploaded byjyip947
- AIRCRAFT IN THE TRANSONIC VELOCITY RANGE.pdfUploaded byChegrani Ahmed
- Final PPT-Matrices & Its Applications_presentationUploaded byDivyam Shah
- Art. WF Assad - A Flexible Software Tool for Temporally-precise Behavioral Control in MatlabUploaded byPaul Rodrigo
- 1.pdfUploaded byjiwei800715
- DSP--LAB#01Uploaded byAwais Bashir
- 06 Mathematics.pdfUploaded bySubhraJyotiBorah
- Computer Concepts C Programming June 2012Uploaded byPrasad C M
- Matllab TutUploaded byAmatou Arrahmen
- ELCE402 Lab Exp00Uploaded bylulu1990
- Algebra-Lineal-Quiz-2-Semana-6.pdfUploaded bynnancy.linares
- Matlab_tutorial_rapido.pdfUploaded byAlafael Araújo
- ME201_Week1Uploaded byKaan Sarıoğlu
- Week0Uploaded byFelipe Chávez Bustamante
- Week0Uploaded byvickydsv
- R-handsonUploaded byAlexandre Santos
- OD Estimation Using Mobile Phone Call RecordsUploaded bycfc95
- Algebra Trabajo Unidad 4Uploaded byeligio vazquez
- SimBasics[1]Uploaded byEirisberto Rodrigues de Moraes
- FORCE AND PRESSURE TESTS OF THE GA(W)-1 AIRFOIL.pdfUploaded byAndre Coraucci
- AssignmentUploaded byAdeel Ali
- Manuscript - Rendall, Hancock and Rasmussen 2017 (Revised).pdfUploaded byMorganRendall
- LorenaUploaded byVinay MP
- R1-063005 TS 36201v010Uploaded bydjcriminal

- Literature SurveyUploaded byakkikirankumar
- Vsphere InstallationUploaded bymgmyatmoe
- Identification of Amazonian Trees With DNA BarcodesUploaded byraunakms
- Advanced Return ManagementUploaded byRahul Chandran
- p&g.pdfUploaded bySaumya Kotiyan
- Notice: Public conservation and recreation areas: Keyhole and Sundance Boat Clubs, Keyhole Reservoir, WY; non-renewal of permitsUploaded byJustia.com
- Gender Disparity in EducationUploaded byGül Erdoğan
- M.Tech June - 2013Uploaded bylog
- Electronic Instrumentation & Control SystemsUploaded byshahnawazuddin
- The Effect of Gamma Radiation on Freezing Tolerance of Chickpea (Cicer Aretinum L.) at in Vitro CultureUploaded byBagus Herwibawa
- Do Animals Feel PainUploaded byAnonymous yADER5
- ITIL_a Guide to Request Fulfilment PDFUploaded byKamran Abk
- Basic Knowledge of CurriculumUploaded byfaza
- Asimov, Isaac - Eyes Do More Than SeeUploaded byNiko Diamesis
- Introducing Proc&c++Uploaded bymanikbasha009
- Statement of ProblemUploaded byapi-3821814
- OverSampling AveragingUploaded byAleem Azhar
- ======================================================================= Restoration Version 2.5.14 5/14/2002 ======================================================================= [Description] Restore Files WhichUploaded byparadise711
- 3.UsersManual.pdfUploaded by黃鼎峰
- ASA StyleUploaded byZufar Abram
- Metrics by Vincanne AdamsUploaded byDuke University Press
- utahfutures i p resultsUploaded byapi-269273808
- rics vs cicsUploaded byvinayaka29
- ME Math ToolUploaded byMario Labastida Ayuban
- Surface Mount TechnologyUploaded bynksharma44
- Invicta-LupahRevolution-150Uploaded byjhayub
- Coconut OilUploaded byPrab Nathan
- Material Pag LisrelUploaded byjuanmarincompositor
- Comparison of different control techniques for three level DC-DC boost converterUploaded byIRJET Journal
- Ultima Underworld II-ManualUploaded byRaúl Pastor Clemente