SlideShare a Scribd company logo
Experiment-2
Trigonometric Function, Complex Numbers & M Files in
MATLAB/ Graph & Plotting in MATLAB
Mr. Kumar Prabhakar
Electronics & Communication Engineering
PDPM
Indian Institute of Information Technology,
Design and Manufacturing Jabalpur
Experiment-2
MATLAB Graph & plotting
Overview
• MATLAB has an excellent set of graphic tools.
• Plotting a given data set or the results of computation is possible with
very few commands.
• Understanding of mathematical equations with graphics is an
enjoyable and very efficient way of learning mathematics
• Being able to plot mathematical functions and data freely is the most
important step, and this section is written to assist you to do just that.
Two Dimensional Plots(2D plots)
Command : plot(x,y) or plot (abscissa, ordinate)
Example: Plot sine function for two cycles.
t=0:pi/200:4*pi;
y=sin(t);
plot(t,y)
Two Dimensional Plots(2D plots)
Adding titles and axis labels: MATLAB also allows labelling of axes.
i.e. x,y axes and title.
Command : xlabel(‘string’)
xlabel() function allows to label the x-axis
Command : ylabel(‘string’)
ylabel() function allows to label the y-axis
Command: title(‘string’)
title()– function allows giving title to our plot.
Note : The order of the xlabel, ylabel, and title commands does not
matter, but we must place them after the plot command.
Two Dimensional Plots(2D plots)
Line styles, Markers and Colours:
Various line types, plot symbols and colors may be obtained with
plot(x,y,s) where s is a character string made from one element from any
or all the following 3 columns given below.
Note : Default colour of graph is blue
Two Dimensional Plots(2D plots)
Controlling Axes
• The scaling and appearance of plot axis can be controlled with the axis
function. To set scaling for the x and y axes on the current 2-D plot,
use the below given command:
Command: axis([xmin xmax ymin ymax])
• Others use full command for axis controlling are:
Command: axis('auto’); axis('square’) ; axis('off ‘) ; axis(tight);
axis(equal)
Two Dimensional Plots(2D plots)
Multiple data sets in one plot
• Many times you may have to plot many functions in different figures
or multiple functions in the same figure. The following piece of code
is an initial attempt to create many plots together.
• For example, these statements plot three related functions of t: y1 = 2*
cos(t), y2 = cos(t), y3 = 0.5 ∗ cos(t), and y4=sin(t) in the interval 0 ≤ t
≤ 2π.
Using single plot command
Using multiple plot commands [hold on hold off]
Two Dimensional Plots(2D plots)
Subplotting
• Sometimes creating a single plot for several functions is not practical
due to different scales and units of the functions.
• Science and Engineering applications, often it is desirable to visualize
many functions together, and subplot command can easily serve the
purpose in place of having many different plots and trying to bring
them together.
Example: The average yearly rainfall and production of rice in a
particular state is given by the following table for 7 consecutive years:
Two Dimensional Plots(2D plots)
• The subplot command allows you to separate the figure into as many
plots as desired, and arrange them all in one figure.
• The general format of this command is : subplot(m,n,p)
Two Dimensional Plots(2D plots)
Create chart with two y-axes
• Command: plotyy(x1,y1,x2,y2)
Produces a plot with two y axes, y1 on the left and y2 on the right
• Command: gtext(‘text’)
Places the string text in the Figure
window at a point specified by the
mouse.
Two Dimensional Plots(2D plots)
Create chart with two y-axes
• Command: yyaxis left
yyaxis right
Specialized plot commands
Two Dimensional Plots(2D plots)
Two Dimensional Plots(2D plots)
Error Bar Plots
Command: errorbar(X,Y,E)
• Experimental data are often represented with plots containing error
bars.
• The bars show the estimated or calculated errors for each data point.
• They can also be used to display the error in an approximate formula.
Example: Keeping two terms in the Taylor series expansion of
𝑐𝑜𝑠𝑥 about 𝑥 = 0 gives 𝑐𝑜𝑠𝑥 ≈ 1 − 𝑥2 2.
Two Dimensional Plots(2D plots)
Box plot
Command: boxplot(x)
• boxplot(x) creates a box plot of the data in x. If x is a vector, boxplot
plots one box. If x is a matrix, boxplot plots one box for each column
of x.
• On each box, the central mark indicates the median, and the bottom
and top edges of the box indicate the 25th and 75th percentiles,
respectively.
• The whiskers extend to the most extreme data points not considered
outliers, and the outliers are plotted individually using the '+' marker
symbol.
Note: Each box visually represents the MPG data for cars from the specified country. Italy's "box"
appears as a single line because the sample data contains only one observation for this group
Two Dimensional Plots(2D plots)
Trigonometry function
• The trigonometric functions in MATLAB calculate standard
trigonometric values in radians or degrees, hyperbolic trigonometric
values in radians, and inverse variants of each function.
• You can use the rad2deg and deg2rad functions to convert between
radians and degrees, or functions like cart2pol to convert between
coordinate systems.
sin Sine of argument in radians
sind Sine of argument in degrees
sinpi Compute sin(X*pi) accurately
asin Inverse sine in radians
asind Inverse sine in degrees
sinh Hyperbolic sine
asinh Inverse hyperbolic sine
cos Cosine of argument in radians
cosd Cosine of argument in degrees
cospi Compute cos(X*pi) accurately
acos Inverse cosine in radians
acosd Inverse cosine in degrees
cosh Hyperbolic cosine
acosh Inverse hyperbolic cosine
tan Tangent of argument in radians
tand Tangent of argument in degrees
atan Inverse tangent in radians
atand Inverse tangent in degrees
atan2 Four-quadrant inverse tangent
atan2d Four-quadrant inverse tangent in degrees
tanh Hyperbolic tangent
atanh Inverse hyperbolic tangent
csc Cosecant of input angle in radians
cscd Cosecant of argument in degrees
acsc Inverse cosecant in radians
acscd Inverse cosecant in degrees
csch Hyperbolic cosecant
acsch Inverse hyperbolic cosecant
sec Secant of angle in radians
secd Secant of argument in degrees
asec Inverse secant in radians
asecd Inverse secant in degrees
sech Hyperbolic secant
asech Inverse hyperbolic secant
Trigonometry function
Degrees/Radians Conversion and Coordinate
Conversion
Degrees/Radians Conversion
deg2rad Convert angle from degrees to radians
rad2deg Convert angle from radians to degrees
cart2pol Transform Cartesian coordinates to polar or cylindrical
cart2sph Transform Cartesian coordinates to spherical
pol2cart Transform polar or cylindrical coordinates to Cartesian
sph2cart Transform spherical coordinates to Cartesian
Coordinate Conversion
Complex Numbers
• In MATLAB, i and j represent the basic imaginary unit. You can use
them to create complex numbers such as 2i+5.
• You can also determine the real and imaginary parts of complex
numbers and compute other common values such as phase and angle.
Basic commands:
abs Absolute value and complex magnitude
angle Phase angle
complex Create complex array
conj Complex conjugate
cplxpair Sort complex numbers into complex conjugate pairs
i Imaginary unit
imag Imaginary part of complex number
isreal Determine whether array uses complex storage
j Imaginary unit
real Real part of complex number
Test Your Understanding
1. Plot the equation 𝑦 = 0.4 1.8𝑥 for 0 ≤ 𝑥 ≤ 35 𝑎𝑛𝑑 0 ≤ 𝑦 ≤ 3.5.
2. Plot the imaginary part versus the real part of the function 0.2 + 0.8𝑖 𝑛
for 0 ≤ 𝑛 ≤ 20. Choose enough points to obtain a smooth curve. Label
each axis and put a title on the plot.
3. Pick a suitable spacing for 𝑡 and 𝑣, and use the subplot command to plot
the function 𝑧 = 𝑒−0.5𝑡
cos 20𝑡 − 6 for 0 ≤ 𝑡 ≤ 8 and the function 𝑢 =
6 log10 𝑣2
+ 20 for −8 ≤ 𝑣 ≤ 8. Label each axis.
4. Plot 𝑦 = sinh 𝑥 and 𝑦 = 0.5𝑒𝑥on the same plot for 0 ≤ 𝑥 ≤ 2. Use a
solid line type for each, the gtext command to label the sinh 𝑥curve, and
the text command to label the 0.5𝑒𝑥
curve. Label the plot axes
appropriately.
5. Use the hold command and the plot command twice to plot 𝑦 = 𝑠𝑖𝑛𝑥and
𝑦 = 𝑥 − 𝑥3
3 on the same plot for0 ≤ 𝑥 ≤ 1. Use a solid line type for
each, and use the gtext command to label each curve. Label the plot axes
appropriately.
Test Your Understanding

More Related Content

Similar to MATLABgraphPlotting.pptx

presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
raghav415187
 
1.2 matlab numerical data
1.2  matlab numerical data1.2  matlab numerical data
1.2 matlab numerical data
TANVIRAHMED611926
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
Khulna University
 
Mit6 094 iap10_lec02
Mit6 094 iap10_lec02Mit6 094 iap10_lec02
Mit6 094 iap10_lec02
Tribhuwan Pant
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
aravindangc
 
More instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxMore instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docx
gilpinleeanna
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
Manchireddy Reddy
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
agnesdcarey33086
 
Basics of matlab
Basics of matlabBasics of matlab
Basics of matlabAnil Maurya
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
kebeAman
 
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
Austin Benson
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
Mattupallipardhu
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
naveen_setty
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
aboma2hawi
 
Lines and planes in space
Lines and planes in spaceLines and planes in space
Lines and planes in space
Faizan Shabbir
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
shahid sultan
 
Analysing simple pendulum using matlab
Analysing simple pendulum using matlabAnalysing simple pendulum using matlab
Analysing simple pendulum using matlab
Akshay Mistri
 

Similar to MATLABgraphPlotting.pptx (20)

Lesson 3
Lesson 3Lesson 3
Lesson 3
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
Matlab1
Matlab1Matlab1
Matlab1
 
1.2 matlab numerical data
1.2  matlab numerical data1.2  matlab numerical data
1.2 matlab numerical data
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Mit6 094 iap10_lec02
Mit6 094 iap10_lec02Mit6 094 iap10_lec02
Mit6 094 iap10_lec02
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
More instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxMore instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docx
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
Basics of matlab
Basics of matlabBasics of matlab
Basics of matlab
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
 
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
Tall-and-skinny Matrix Computations in MapReduce (ICME colloquium)
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
Lines and planes in space
Lines and planes in spaceLines and planes in space
Lines and planes in space
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
Analysing simple pendulum using matlab
Analysing simple pendulum using matlabAnalysing simple pendulum using matlab
Analysing simple pendulum using matlab
 
Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 

Recently uploaded

road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
top1002
 
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdfThe Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
Nettur Technical Training Foundation
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
veerababupersonal22
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 

Recently uploaded (20)

road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
 
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdfThe Role of Electrical and Electronics Engineers in IOT Technology.pdf
The Role of Electrical and Electronics Engineers in IOT Technology.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 

MATLABgraphPlotting.pptx

  • 1. Experiment-2 Trigonometric Function, Complex Numbers & M Files in MATLAB/ Graph & Plotting in MATLAB Mr. Kumar Prabhakar Electronics & Communication Engineering PDPM Indian Institute of Information Technology, Design and Manufacturing Jabalpur
  • 2. Experiment-2 MATLAB Graph & plotting Overview • MATLAB has an excellent set of graphic tools. • Plotting a given data set or the results of computation is possible with very few commands. • Understanding of mathematical equations with graphics is an enjoyable and very efficient way of learning mathematics • Being able to plot mathematical functions and data freely is the most important step, and this section is written to assist you to do just that.
  • 3. Two Dimensional Plots(2D plots) Command : plot(x,y) or plot (abscissa, ordinate) Example: Plot sine function for two cycles. t=0:pi/200:4*pi; y=sin(t); plot(t,y)
  • 4. Two Dimensional Plots(2D plots) Adding titles and axis labels: MATLAB also allows labelling of axes. i.e. x,y axes and title. Command : xlabel(‘string’) xlabel() function allows to label the x-axis Command : ylabel(‘string’) ylabel() function allows to label the y-axis Command: title(‘string’) title()– function allows giving title to our plot. Note : The order of the xlabel, ylabel, and title commands does not matter, but we must place them after the plot command.
  • 5. Two Dimensional Plots(2D plots) Line styles, Markers and Colours: Various line types, plot symbols and colors may be obtained with plot(x,y,s) where s is a character string made from one element from any or all the following 3 columns given below. Note : Default colour of graph is blue
  • 6. Two Dimensional Plots(2D plots) Controlling Axes • The scaling and appearance of plot axis can be controlled with the axis function. To set scaling for the x and y axes on the current 2-D plot, use the below given command: Command: axis([xmin xmax ymin ymax]) • Others use full command for axis controlling are: Command: axis('auto’); axis('square’) ; axis('off ‘) ; axis(tight); axis(equal)
  • 7. Two Dimensional Plots(2D plots) Multiple data sets in one plot • Many times you may have to plot many functions in different figures or multiple functions in the same figure. The following piece of code is an initial attempt to create many plots together. • For example, these statements plot three related functions of t: y1 = 2* cos(t), y2 = cos(t), y3 = 0.5 ∗ cos(t), and y4=sin(t) in the interval 0 ≤ t ≤ 2π. Using single plot command Using multiple plot commands [hold on hold off]
  • 8. Two Dimensional Plots(2D plots) Subplotting • Sometimes creating a single plot for several functions is not practical due to different scales and units of the functions. • Science and Engineering applications, often it is desirable to visualize many functions together, and subplot command can easily serve the purpose in place of having many different plots and trying to bring them together. Example: The average yearly rainfall and production of rice in a particular state is given by the following table for 7 consecutive years:
  • 9. Two Dimensional Plots(2D plots) • The subplot command allows you to separate the figure into as many plots as desired, and arrange them all in one figure. • The general format of this command is : subplot(m,n,p)
  • 10. Two Dimensional Plots(2D plots) Create chart with two y-axes • Command: plotyy(x1,y1,x2,y2) Produces a plot with two y axes, y1 on the left and y2 on the right • Command: gtext(‘text’) Places the string text in the Figure window at a point specified by the mouse.
  • 11. Two Dimensional Plots(2D plots) Create chart with two y-axes • Command: yyaxis left yyaxis right
  • 12. Specialized plot commands Two Dimensional Plots(2D plots)
  • 13. Two Dimensional Plots(2D plots) Error Bar Plots Command: errorbar(X,Y,E) • Experimental data are often represented with plots containing error bars. • The bars show the estimated or calculated errors for each data point. • They can also be used to display the error in an approximate formula. Example: Keeping two terms in the Taylor series expansion of 𝑐𝑜𝑠𝑥 about 𝑥 = 0 gives 𝑐𝑜𝑠𝑥 ≈ 1 − 𝑥2 2.
  • 14. Two Dimensional Plots(2D plots) Box plot Command: boxplot(x) • boxplot(x) creates a box plot of the data in x. If x is a vector, boxplot plots one box. If x is a matrix, boxplot plots one box for each column of x. • On each box, the central mark indicates the median, and the bottom and top edges of the box indicate the 25th and 75th percentiles, respectively. • The whiskers extend to the most extreme data points not considered outliers, and the outliers are plotted individually using the '+' marker symbol.
  • 15. Note: Each box visually represents the MPG data for cars from the specified country. Italy's "box" appears as a single line because the sample data contains only one observation for this group Two Dimensional Plots(2D plots)
  • 16. Trigonometry function • The trigonometric functions in MATLAB calculate standard trigonometric values in radians or degrees, hyperbolic trigonometric values in radians, and inverse variants of each function. • You can use the rad2deg and deg2rad functions to convert between radians and degrees, or functions like cart2pol to convert between coordinate systems. sin Sine of argument in radians sind Sine of argument in degrees sinpi Compute sin(X*pi) accurately asin Inverse sine in radians asind Inverse sine in degrees sinh Hyperbolic sine asinh Inverse hyperbolic sine cos Cosine of argument in radians cosd Cosine of argument in degrees cospi Compute cos(X*pi) accurately acos Inverse cosine in radians acosd Inverse cosine in degrees cosh Hyperbolic cosine acosh Inverse hyperbolic cosine
  • 17. tan Tangent of argument in radians tand Tangent of argument in degrees atan Inverse tangent in radians atand Inverse tangent in degrees atan2 Four-quadrant inverse tangent atan2d Four-quadrant inverse tangent in degrees tanh Hyperbolic tangent atanh Inverse hyperbolic tangent csc Cosecant of input angle in radians cscd Cosecant of argument in degrees acsc Inverse cosecant in radians acscd Inverse cosecant in degrees csch Hyperbolic cosecant acsch Inverse hyperbolic cosecant sec Secant of angle in radians secd Secant of argument in degrees asec Inverse secant in radians asecd Inverse secant in degrees sech Hyperbolic secant asech Inverse hyperbolic secant Trigonometry function
  • 18. Degrees/Radians Conversion and Coordinate Conversion Degrees/Radians Conversion deg2rad Convert angle from degrees to radians rad2deg Convert angle from radians to degrees cart2pol Transform Cartesian coordinates to polar or cylindrical cart2sph Transform Cartesian coordinates to spherical pol2cart Transform polar or cylindrical coordinates to Cartesian sph2cart Transform spherical coordinates to Cartesian Coordinate Conversion
  • 19. Complex Numbers • In MATLAB, i and j represent the basic imaginary unit. You can use them to create complex numbers such as 2i+5. • You can also determine the real and imaginary parts of complex numbers and compute other common values such as phase and angle. Basic commands: abs Absolute value and complex magnitude angle Phase angle complex Create complex array conj Complex conjugate cplxpair Sort complex numbers into complex conjugate pairs i Imaginary unit imag Imaginary part of complex number isreal Determine whether array uses complex storage j Imaginary unit real Real part of complex number
  • 20. Test Your Understanding 1. Plot the equation 𝑦 = 0.4 1.8𝑥 for 0 ≤ 𝑥 ≤ 35 𝑎𝑛𝑑 0 ≤ 𝑦 ≤ 3.5. 2. Plot the imaginary part versus the real part of the function 0.2 + 0.8𝑖 𝑛 for 0 ≤ 𝑛 ≤ 20. Choose enough points to obtain a smooth curve. Label each axis and put a title on the plot. 3. Pick a suitable spacing for 𝑡 and 𝑣, and use the subplot command to plot the function 𝑧 = 𝑒−0.5𝑡 cos 20𝑡 − 6 for 0 ≤ 𝑡 ≤ 8 and the function 𝑢 = 6 log10 𝑣2 + 20 for −8 ≤ 𝑣 ≤ 8. Label each axis. 4. Plot 𝑦 = sinh 𝑥 and 𝑦 = 0.5𝑒𝑥on the same plot for 0 ≤ 𝑥 ≤ 2. Use a solid line type for each, the gtext command to label the sinh 𝑥curve, and the text command to label the 0.5𝑒𝑥 curve. Label the plot axes appropriately. 5. Use the hold command and the plot command twice to plot 𝑦 = 𝑠𝑖𝑛𝑥and 𝑦 = 𝑥 − 𝑥3 3 on the same plot for0 ≤ 𝑥 ≤ 1. Use a solid line type for each, and use the gtext command to label each curve. Label the plot axes appropriately.