This document discusses various MATLAB plotting commands and techniques. It begins by explaining how to create basic 2D plots using the plot() command to plot x-y data or a function. It also covers formatting plots by adding titles, labels, legends etc. The document then discusses plotting multiple graphs in the same figure using either the plot() command or hold on/off commands. Finally, it demonstrates how to create multiple subplots on one figure using the subplot command.
This document provides an overview of plotting functions in MATLAB. It discusses how to generate basic and 3D plots, customize plots using options like color, style and labels, and control the plot appearance using functions such as axis, title, legend. Examples are given to illustrate plotting a simple function, holding multiple plots, using subplots, and generating surface plots. The document also covers plotting in 3D using functions like surf, plot3 and manipulating axes properties.
This document discusses various plotting tools in Matlab, including:
- The plot and stem functions for plotting data values against their index or specified x-values.
- Tools for labeling axes, titles, legends, and setting axis properties.
- The subplot function for dividing the figure window into multiple plots.
- Functions for turning the grid on/off and holding plots.
- Examples of simple 2D and 3D function plots.
The document discusses MATLAB files and functions. It describes that:
1) Functions and scripts are stored in .m files. The MATLAB workspace can be saved in .mat files for easy loading and efficient access. Plots can be saved in .fig files.
2) Scripts contain commands that run when the file is run. Functions have their own variables, accept inputs, and return outputs.
3) Comments start with % and help document code. Control flow includes conditional (if/else) and loop (for/while) statements. Functions terminate with return.
How to 2D plots in Matlab. Easy steps to graph mathematical functions.
You have to define your interval of interest and consider a step in your independent vector, then you have to define your function and use an appropriate 2D built-in function.
More information and examples:
http://matrixlab-examples.com/matlab-plot-2tier.html
This document provides an overview of MATLAB including its history, applications, development environment, built-in functions, and toolboxes. MATLAB stands for Matrix Laboratory and was originally developed in the 1970s at the University of New Mexico to provide an interactive environment for matrix computations. It has since grown to be a comprehensive programming language and environment used widely in technical computing across many domains including engineering, science, and finance. The key components of MATLAB are its development environment, mathematical function library, programming language, graphics capabilities, and application programming interface. It also includes a variety of toolboxes that provide domain-specific functionality in areas like signal processing, neural networks, and optimization.
This document provides an introduction to MATLAB. It discusses what MATLAB is, the MATLAB screen interface, variables and arrays, basic arithmetic and relational operators, functions, plotting, and matrices. Key aspects covered include creating and using variables, performing calculations, controlling precision of outputs, getting help, and using basic mathematical functions in MATLAB. The document is intended to familiarize users with essential MATLAB features for use in courses.
In MATLAB, a vector is created by assigning the elements of the vector to a variable. This can be done in several ways depending on the source of the information.
—Enter an explicit list of elements
—Load matrices from external data files
—Using built-in functions
—Using own functions in M-files
This is the slides of the UCLA School of Engineering Matlab workshop on Matlab graphics.
Learning Matlab graphics by examples:
- In 2 hours, you will be able to create publication-quality plots.
- Starts from the basic 2D line plots to more advanced 3D plots.
- You will also learn some advanced topics like fine-tuning the appearance of your figure and the concept of handles.
- You will be able to create amazing animations: we use 2D wave equation and Lorentz attractor as examples.
This document provides an overview of plotting functions in MATLAB. It discusses how to generate basic and 3D plots, customize plots using options like color, style and labels, and control the plot appearance using functions such as axis, title, legend. Examples are given to illustrate plotting a simple function, holding multiple plots, using subplots, and generating surface plots. The document also covers plotting in 3D using functions like surf, plot3 and manipulating axes properties.
This document discusses various plotting tools in Matlab, including:
- The plot and stem functions for plotting data values against their index or specified x-values.
- Tools for labeling axes, titles, legends, and setting axis properties.
- The subplot function for dividing the figure window into multiple plots.
- Functions for turning the grid on/off and holding plots.
- Examples of simple 2D and 3D function plots.
The document discusses MATLAB files and functions. It describes that:
1) Functions and scripts are stored in .m files. The MATLAB workspace can be saved in .mat files for easy loading and efficient access. Plots can be saved in .fig files.
2) Scripts contain commands that run when the file is run. Functions have their own variables, accept inputs, and return outputs.
3) Comments start with % and help document code. Control flow includes conditional (if/else) and loop (for/while) statements. Functions terminate with return.
How to 2D plots in Matlab. Easy steps to graph mathematical functions.
You have to define your interval of interest and consider a step in your independent vector, then you have to define your function and use an appropriate 2D built-in function.
More information and examples:
http://matrixlab-examples.com/matlab-plot-2tier.html
This document provides an overview of MATLAB including its history, applications, development environment, built-in functions, and toolboxes. MATLAB stands for Matrix Laboratory and was originally developed in the 1970s at the University of New Mexico to provide an interactive environment for matrix computations. It has since grown to be a comprehensive programming language and environment used widely in technical computing across many domains including engineering, science, and finance. The key components of MATLAB are its development environment, mathematical function library, programming language, graphics capabilities, and application programming interface. It also includes a variety of toolboxes that provide domain-specific functionality in areas like signal processing, neural networks, and optimization.
This document provides an introduction to MATLAB. It discusses what MATLAB is, the MATLAB screen interface, variables and arrays, basic arithmetic and relational operators, functions, plotting, and matrices. Key aspects covered include creating and using variables, performing calculations, controlling precision of outputs, getting help, and using basic mathematical functions in MATLAB. The document is intended to familiarize users with essential MATLAB features for use in courses.
In MATLAB, a vector is created by assigning the elements of the vector to a variable. This can be done in several ways depending on the source of the information.
—Enter an explicit list of elements
—Load matrices from external data files
—Using built-in functions
—Using own functions in M-files
This is the slides of the UCLA School of Engineering Matlab workshop on Matlab graphics.
Learning Matlab graphics by examples:
- In 2 hours, you will be able to create publication-quality plots.
- Starts from the basic 2D line plots to more advanced 3D plots.
- You will also learn some advanced topics like fine-tuning the appearance of your figure and the concept of handles.
- You will be able to create amazing animations: we use 2D wave equation and Lorentz attractor as examples.
This document describes the digital differential analyzer (DDA) algorithm for rasterizing lines, triangles, and polygons in computer graphics. It discusses implementing DDA using floating-point or integer arithmetic. The DDA line drawing algorithm works by incrementing either the x or y coordinate by 1 each step depending on whether the slope is less than or greater than 1. Pseudocode is provided to illustrate the algorithm. Potential drawbacks of DDA are also mentioned, such as the expense of rounding operations.
This document provides an introduction and overview of Matlab. It outlines the main Matlab screen components, discusses variables, arrays, matrices and indexing. It also covers basic operators, plotting functions, flow control, using M-files and writing user-defined functions. The key topics covered in 3 sentences or less are: Matlab allows matrix operations and plotting, has variables without types, and functions can be defined and saved in M-files to be called from the command window or other code.
The document discusses various 2D and 3D transformations including translation, scaling, rotation, reflection, shearing, and homogeneous coordinates. It provides the mathematical definitions and matrix representations for each transformation type in 2D and 3D. It also covers topics like composition and inverse of transformations, classification of transformations, and properties of rigid body transformations.
The document discusses different computer graphics display systems and algorithms for drawing lines. It describes raster scan and random scan display systems. Raster scan systems sweep an electron beam across the screen row by row to draw the image based on values stored in a frame buffer. It also covers the digital differential analyzer (DDA) and Bresenham's algorithms for drawing lines on a digital display. DDA calculates increments to move the line incrementally pixel by pixel, while Bresenham's uses a decision parameter to efficiently draw lines on a raster display. An example demonstrates applying each algorithm to draw a line between two points.
This document discusses matrices and arrays in MATLAB. It defines matrices and vectors, and notes that MATLAB treats all variables as matrices. It explains how to enter matrices in MATLAB by listing elements separated by commas and semicolons. It also discusses built-in functions to generate matrices filled with zeros, ones, random values, or an identity matrix. The document covers operations on matrices like addition, subtraction, and multiplication. It explains how to extract sub-matrices and elements using indexing and introduces the colon operator.
Series solutions at ordinary point and regular singular pointvaibhav tailor
The document discusses series solutions for second order linear differential equations near ordinary and regular singular points.
It defines an ordinary point as a point where the functions p(x) and q(x) in the normalized form of the differential equation are analytic. Near an ordinary point, there exist two linearly independent power series solutions of the form Σcn(x-a)n that converge within the radii of convergence of p(x) and q(x).
It also discusses finding series solutions near a regular singular point x0=0, where the limits of p(x) and q(x) as x approaches 0 exist. An initial guess of a power series solution with exponent r is made, and the
This document provides an overview of MATLAB for geoscientists. It describes MATLAB as a high-level language and interactive environment for numerical computation, visualization, and programming. Key features of MATLAB include its high-level language for numerical analysis, interactive environment, built-in mathematical functions, graphics for data visualization, and tools for algorithm and application development. The document discusses matrices, variables, basic arithmetic and programming in MATLAB, and provides examples of using MATLAB for tasks like plotting functions, solving equations, and working with arrays.
This presentation provides an introduction to MATLAB. It discusses what MATLAB is, its advantages and disadvantages, typical uses, and how to start the MATLAB environment. It demonstrates basic MATLAB commands like plotting a sine wave and performing calculations. It also covers different types of files used in MATLAB like M-files, MAT-files and MEX-files. The presentation shows how to address matrices, perform matrix operations, and use functions to build matrices. It encourages viewers to access the online MATLAB helpdesk for additional information and support.
This document contains solutions to exercises involving double integration using Cartesian and polar coordinates. It includes 8 exercises with solutions involving double integrals over various regions in 2D planes. The solutions calculate the double integrals using different orders and techniques of integration, including changing to polar coordinates.
This document discusses linear independence, basis, and dimension in linear algebra. It defines linear independence as vectors being linearly independent if the only solution that produces the zero vector is the trivial solution with all coefficients equal to zero. A basis is defined as a set of linearly independent vectors that span the vector space. The dimension of a vector space is the number of vectors in any basis of that space. The dimensions of the four fundamental subspaces (row space, column space, nullspace, and left nullspace) of a matrix are defined in terms of the rank of the matrix.
This includes different line drawing algorithms,circle,ellipse generating algorithms, filled area primitives,flood fill ,boundary fill algorithms,raster scan fill approaches.
This document discusses cubic spline interpolation. Cubic splines are piecewise cubic polynomials that are continuously differentiable and match function values at sample points. They provide a smooth interpolation that avoids oscillations seen in higher-degree global polynomials. The document outlines the construction of cubic spline interpolation, including determining the coefficients for each cubic polynomial piece based on function values and derivatives at nodes. An example interpolates the function f(x)=x^4 on the interval [-1,1] using cubic splines.
Here are the key steps to find the eigenvalues of the given matrix:
1) Write the characteristic equation: det(A - λI) = 0
2) Expand the determinant: (1-λ)(-2-λ) - 4 = 0
3) Simplify and factor: λ(λ + 1)(λ + 2) = 0
4) Find the roots: λ1 = 0, λ2 = -1, λ3 = -2
Therefore, the eigenvalues of the given matrix are -1 and -2.
Here are the key points about scalar-matrix addition in MATLAB:
- a is a scalar (single value)
- b is a matrix (2D array)
- To add a scalar to a matrix, MATLAB adds the scalar to each element of the matrix
- c = b + a performs element-wise addition, adding the value of a (which is 3) to each element of b
- The result c is the matrix b with 3 added to each element
So c would be:
c =
4 5 6
7 8 9
Scalar-matrix operations in MATLAB perform the operation on each element of the matrix.
This document provides an overview of data types and operators in MATLAB. It discusses the main data types including matrices, vectors, strings, structures, cell arrays, and numeric precision. It describes how to create and manipulate different data types using vectors, indexing, and the colon operator. The document also covers common operators for arithmetic, relational, logical, and bitwise operations. Structures are highlighted as useful for passing arguments to functions or making code robust against changes.
Double integrals are used to calculate properties of planar laminas such as mass, center of mass, and moments of inertia by integrating a density function over a region. The inner integral is evaluated first, treating the other variable as a constant. Properties include:
1) Total mass by double integrating the density function over the region.
2) Center of mass coordinates by taking moments about axes and dividing by total mass.
3) Moments of inertia by double integrating the distance squared from an axis times the density.
This document discusses creating and manipulating arrays in MATLAB. It covers:
- Creating one-dimensional arrays (vectors) using known values, spacing, or number of elements.
- Creating two-dimensional arrays (matrices) by specifying rows and ensuring each row has the same number of columns.
- Basic array commands like zeros, ones, and eye to create arrays filled with zeros, ones, or an identity matrix.
- Transposing arrays with the ' operator.
- Accessing and assigning values to individual elements or ranges of elements using indexing and colon notation.
- Adding elements to existing arrays by assigning values to undefined indices or appending rows/columns.
The document discusses vector spaces and related linear algebra concepts. It defines vector spaces and lists the axioms that must be satisfied. Examples of vector spaces include the set of all pairs of real numbers and the space of 2x2 symmetric matrices. The document also discusses subspaces, linear combinations, span, basis, dimension, row space, column space, null space, rank, nullity, and change of basis. It provides examples and explanations of these fundamental linear algebra topics.
The document discusses partial differentiation and its applications. It covers functions of two variables, first and second partial derivatives, and applications including the Cobb-Douglas production function and finding marginal productivity from a production function. Examples are provided to demonstrate calculating partial derivatives of various functions and applying partial derivatives in contexts like production analysis.
Introduction
Plotting basic 2-D plots.
The plot command
The fplot command
Plotting multiple graphs in the same plot
Formatting plots
USING THE plot() COMMAND TO PLOT
MULTIPLE GRAPHS IN THE SAME PLOT
MATLAB PROGRAM TO PLOT VI CHARACTERISTICS OF A DIODE
SUMMARY
The document describes using MATLAB to plot various two-dimensional and three-dimensional plots, generate different types of signals used in signal processing, compare discrete and continuous ramp signals, compute the linear convolution of two sequences, illustrate folding and time shifting of sequences. MATLAB commands like plot, plot3, stem, conv are used to generate graphs and signals. Various experiments are presented on plotting functions, signals, and operations like convolution in MATLAB.
This document describes the digital differential analyzer (DDA) algorithm for rasterizing lines, triangles, and polygons in computer graphics. It discusses implementing DDA using floating-point or integer arithmetic. The DDA line drawing algorithm works by incrementing either the x or y coordinate by 1 each step depending on whether the slope is less than or greater than 1. Pseudocode is provided to illustrate the algorithm. Potential drawbacks of DDA are also mentioned, such as the expense of rounding operations.
This document provides an introduction and overview of Matlab. It outlines the main Matlab screen components, discusses variables, arrays, matrices and indexing. It also covers basic operators, plotting functions, flow control, using M-files and writing user-defined functions. The key topics covered in 3 sentences or less are: Matlab allows matrix operations and plotting, has variables without types, and functions can be defined and saved in M-files to be called from the command window or other code.
The document discusses various 2D and 3D transformations including translation, scaling, rotation, reflection, shearing, and homogeneous coordinates. It provides the mathematical definitions and matrix representations for each transformation type in 2D and 3D. It also covers topics like composition and inverse of transformations, classification of transformations, and properties of rigid body transformations.
The document discusses different computer graphics display systems and algorithms for drawing lines. It describes raster scan and random scan display systems. Raster scan systems sweep an electron beam across the screen row by row to draw the image based on values stored in a frame buffer. It also covers the digital differential analyzer (DDA) and Bresenham's algorithms for drawing lines on a digital display. DDA calculates increments to move the line incrementally pixel by pixel, while Bresenham's uses a decision parameter to efficiently draw lines on a raster display. An example demonstrates applying each algorithm to draw a line between two points.
This document discusses matrices and arrays in MATLAB. It defines matrices and vectors, and notes that MATLAB treats all variables as matrices. It explains how to enter matrices in MATLAB by listing elements separated by commas and semicolons. It also discusses built-in functions to generate matrices filled with zeros, ones, random values, or an identity matrix. The document covers operations on matrices like addition, subtraction, and multiplication. It explains how to extract sub-matrices and elements using indexing and introduces the colon operator.
Series solutions at ordinary point and regular singular pointvaibhav tailor
The document discusses series solutions for second order linear differential equations near ordinary and regular singular points.
It defines an ordinary point as a point where the functions p(x) and q(x) in the normalized form of the differential equation are analytic. Near an ordinary point, there exist two linearly independent power series solutions of the form Σcn(x-a)n that converge within the radii of convergence of p(x) and q(x).
It also discusses finding series solutions near a regular singular point x0=0, where the limits of p(x) and q(x) as x approaches 0 exist. An initial guess of a power series solution with exponent r is made, and the
This document provides an overview of MATLAB for geoscientists. It describes MATLAB as a high-level language and interactive environment for numerical computation, visualization, and programming. Key features of MATLAB include its high-level language for numerical analysis, interactive environment, built-in mathematical functions, graphics for data visualization, and tools for algorithm and application development. The document discusses matrices, variables, basic arithmetic and programming in MATLAB, and provides examples of using MATLAB for tasks like plotting functions, solving equations, and working with arrays.
This presentation provides an introduction to MATLAB. It discusses what MATLAB is, its advantages and disadvantages, typical uses, and how to start the MATLAB environment. It demonstrates basic MATLAB commands like plotting a sine wave and performing calculations. It also covers different types of files used in MATLAB like M-files, MAT-files and MEX-files. The presentation shows how to address matrices, perform matrix operations, and use functions to build matrices. It encourages viewers to access the online MATLAB helpdesk for additional information and support.
This document contains solutions to exercises involving double integration using Cartesian and polar coordinates. It includes 8 exercises with solutions involving double integrals over various regions in 2D planes. The solutions calculate the double integrals using different orders and techniques of integration, including changing to polar coordinates.
This document discusses linear independence, basis, and dimension in linear algebra. It defines linear independence as vectors being linearly independent if the only solution that produces the zero vector is the trivial solution with all coefficients equal to zero. A basis is defined as a set of linearly independent vectors that span the vector space. The dimension of a vector space is the number of vectors in any basis of that space. The dimensions of the four fundamental subspaces (row space, column space, nullspace, and left nullspace) of a matrix are defined in terms of the rank of the matrix.
This includes different line drawing algorithms,circle,ellipse generating algorithms, filled area primitives,flood fill ,boundary fill algorithms,raster scan fill approaches.
This document discusses cubic spline interpolation. Cubic splines are piecewise cubic polynomials that are continuously differentiable and match function values at sample points. They provide a smooth interpolation that avoids oscillations seen in higher-degree global polynomials. The document outlines the construction of cubic spline interpolation, including determining the coefficients for each cubic polynomial piece based on function values and derivatives at nodes. An example interpolates the function f(x)=x^4 on the interval [-1,1] using cubic splines.
Here are the key steps to find the eigenvalues of the given matrix:
1) Write the characteristic equation: det(A - λI) = 0
2) Expand the determinant: (1-λ)(-2-λ) - 4 = 0
3) Simplify and factor: λ(λ + 1)(λ + 2) = 0
4) Find the roots: λ1 = 0, λ2 = -1, λ3 = -2
Therefore, the eigenvalues of the given matrix are -1 and -2.
Here are the key points about scalar-matrix addition in MATLAB:
- a is a scalar (single value)
- b is a matrix (2D array)
- To add a scalar to a matrix, MATLAB adds the scalar to each element of the matrix
- c = b + a performs element-wise addition, adding the value of a (which is 3) to each element of b
- The result c is the matrix b with 3 added to each element
So c would be:
c =
4 5 6
7 8 9
Scalar-matrix operations in MATLAB perform the operation on each element of the matrix.
This document provides an overview of data types and operators in MATLAB. It discusses the main data types including matrices, vectors, strings, structures, cell arrays, and numeric precision. It describes how to create and manipulate different data types using vectors, indexing, and the colon operator. The document also covers common operators for arithmetic, relational, logical, and bitwise operations. Structures are highlighted as useful for passing arguments to functions or making code robust against changes.
Double integrals are used to calculate properties of planar laminas such as mass, center of mass, and moments of inertia by integrating a density function over a region. The inner integral is evaluated first, treating the other variable as a constant. Properties include:
1) Total mass by double integrating the density function over the region.
2) Center of mass coordinates by taking moments about axes and dividing by total mass.
3) Moments of inertia by double integrating the distance squared from an axis times the density.
This document discusses creating and manipulating arrays in MATLAB. It covers:
- Creating one-dimensional arrays (vectors) using known values, spacing, or number of elements.
- Creating two-dimensional arrays (matrices) by specifying rows and ensuring each row has the same number of columns.
- Basic array commands like zeros, ones, and eye to create arrays filled with zeros, ones, or an identity matrix.
- Transposing arrays with the ' operator.
- Accessing and assigning values to individual elements or ranges of elements using indexing and colon notation.
- Adding elements to existing arrays by assigning values to undefined indices or appending rows/columns.
The document discusses vector spaces and related linear algebra concepts. It defines vector spaces and lists the axioms that must be satisfied. Examples of vector spaces include the set of all pairs of real numbers and the space of 2x2 symmetric matrices. The document also discusses subspaces, linear combinations, span, basis, dimension, row space, column space, null space, rank, nullity, and change of basis. It provides examples and explanations of these fundamental linear algebra topics.
The document discusses partial differentiation and its applications. It covers functions of two variables, first and second partial derivatives, and applications including the Cobb-Douglas production function and finding marginal productivity from a production function. Examples are provided to demonstrate calculating partial derivatives of various functions and applying partial derivatives in contexts like production analysis.
Introduction
Plotting basic 2-D plots.
The plot command
The fplot command
Plotting multiple graphs in the same plot
Formatting plots
USING THE plot() COMMAND TO PLOT
MULTIPLE GRAPHS IN THE SAME PLOT
MATLAB PROGRAM TO PLOT VI CHARACTERISTICS OF A DIODE
SUMMARY
The document describes using MATLAB to plot various two-dimensional and three-dimensional plots, generate different types of signals used in signal processing, compare discrete and continuous ramp signals, compute the linear convolution of two sequences, illustrate folding and time shifting of sequences. MATLAB commands like plot, plot3, stem, conv are used to generate graphs and signals. Various experiments are presented on plotting functions, signals, and operations like convolution in MATLAB.
The document discusses various topics related to graphics and plotting in MATLAB including: the plot command for creating 2D and 3D plots; options for specifying line styles; using linspace to generate uniformly spaced vectors; adding labels, titles, and text to figures; displaying data using plots, stem plots, bar charts; and including multiple graphs in the same figure. Key graphing functions covered are plot, stem, bar, title, xlabel, ylabel, text, and linspace. The document also includes examples of MATLAB code for generating various types of graphs and annotating them.
This document introduces new commands in Matlab lesson 3 for creating plots, including plot(x,y) to create Cartesian plots, semilogx(x,y) to plot log(x) vs y, and bar(x) to create bar graphs. It also discusses using titles, labels, text and grids with plots, and describes polar, multiple, and fancy plots using different line styles and point markers. The document concludes with instructions for printing and saving graphic plots.
To plot graphs in MATLAB, you must:
1. Define the range of values for the x-axis variable
2. Define the function as y = f(x)
3. Use the plot command plot(x,y) to generate the graph
MATLAB allows adding titles, labels, grid lines, adjusting axis scales, and plotting multiple functions on the same graph. Subplot allows generating multiple plots in the same figure.
Here are the steps to plot the given functions using MATLAB:
1. Plot y = 0.4x + 1.8 for 0 ≤ x ≤ 35 and 0 ≤ y ≤ 3.5:
x = 0:35;
y = 0.4.*x + 1.8;
plot(x,y)
xlim([0 35])
ylim([0 3.5])
2. Plot imaginary vs real parts of 0.2 + 0.8i*n for 0 ≤ n ≤ 20:
n = 0:20;
z = 0.2 + 0.8i*n;
plot(real(z),imag(z))
xlabel('Real Part')
17, r) -,r I : -l
19.t:...: 1
21.2t-31:4
/ 23. ^t: -rr - 1)t I,r r.= ll-vl
11 1
Evaluating a Function In Exercises 29-14, evaluate the
function at each specified value of the independent
variable and simplify.
29.fO-3t+t
(a) f(2) (b) /(-4) (c) f(r + 2)
30. s(y) :1 - 3y
(a) s(o) tul s(l) (c) s(s + 2)
tlzt.t(t):t2-2t
(a) h(.2) ft) /,(1.s) (c) h(x + 2)
32. v(r) - !rr3
(a) v(3) (b) Y(;) k) v(2r)
33./(.-r)::-./y
@) f(a) (u) l(0.2s) (c') [email protected])
3a.f(x)- aE+8+2
(a) f (-+) (b) /(8)
1
' x'-9
(a) q(-3) (b) q(z)
)t2+\
36. ./(r)- t'
(il qQ) 0) q(o)
lrl
37. i(r) : "'x
ar f(e) (b) /(-e)
38. -.,. : -r *4
: , -i (b) /(_5)
-, - l. x<0
'lq -, - l. .r > 0'\-
'\-
6r t(0)
', - -:. -r < 0t.
> |
1..
1OG Chapter I Functjons and Their Graphs
Testing for Functions Represented Algebraically In
Exercises 77-28. determine whether the equation
represents,r' as a function of r.
18.x:]2+1
20. y :-lf+ 5
22.r:-.y+5
24.r'l!2:3
20. lyl :1-x
28.r,:8
(c) /(x - 8)
(c) q(y + 3)
(.c) q(.- x)
(c) /(t)
(c) f(t)
(c) JQ)
,cl .f(l)
Evalr.rating a Fr.lnction In Exercises 45-48, assume that
the domain of/is the setA = {-2, - 1, 0, 1, 2}. Determine
the set of ordered pairs representing the function/.
[.rr-4. x<o42.fG)-1r_r,., r>0L1 - i.\
(il f?2) (b) /(0)
[.r- ]. t<0
I
a3.f(x)-1a. 0<r<2
L*, + t. r > 2
(a) .f(.-2) (b) /(1)
(s - ), r < otJ
44. ffrr --]s. us r < I
l.+*- r, r2 l
(a) J(. 2) (b) /(])
(c) /(1)
@ f(a)
(c) f(t)
a6. .f(.x) : x2 - 3
as. /(x) : lx + 1l
45. f(x) - x2
a7. f(x): lxl + z
Evaluating a Function In Exercises 49 and 50, complete
the tahle.
4s. h(t): llr + :l
l" - ?l50..f(r) -:
Finding the lnputs That Have Outputs of Zers In
Exercises 51-54, find all values of x such that/(r) = g'
st. 16) : 15 - 3x 52. f(x): 5r * I
3r-4
sa. f(x') - 2r-3s3. /(x) :
Finding the Dornain of a Function In Exercises 55-6J.
find the domain of the function.
,l ss. fG): 5x2 + 2x - | s6. s(ir) : 7 - 2x2
4-3v
57. hhl - ' 58. ,s( r') -I y-)
se. /(x) - 1C - 1 60. /(x) : X/" + 3x
. t 3 l0
{ el. gtrt - ' - 62. h(r) - .., 1..I f t- i LA
r'*2 -,8+6
64./(:r) :--' o f .t
t -5 -4 -3 -1
It(r)
,t 0 l2
I
2
4
/(')
63. s(.v) : 5- 10
the Domain and Range of a Function In 1)
mriffs 65-68, use a graphing utility to graph the
hhu Find the domain and range of the function.
. ,.-
-E' - \
+ i 66. f(x): 1F I 1
68. g(x) : I, - sl.j1- -r,-; : i1r + 3l
I. Geometry Write the areaA of a circle as a function of
rs --ircumference C.
il" Cmmetry Write the arca A of an equilaterai tiangle
"ts i tunction of the length s of its sides.
1!- E4loration An open box of maximum volume is to
s made from a square piece of mateial, 24 centimeters
cm a side, by cutting equal squares from the corners and
uuia-e up the sides (see figure).
,"1 , The table shows the volume 7 (in cubic centimeters)
of the box for various heights x (in centimeters).
L-se the table to estimate the maximum volume.
i Plot the points (x, I/) from the table in part (a). Does
rtre relation defined.
This document covers various topics related to MATLAB including loops, control flow, plotting, and 3D graphics. It discusses for loops, while loops, and switch statements for control flow. It provides examples of plotting functions like plot, hold, title, ylabel, legend, and properties that can be applied. It also demonstrates how to generate 3D surface and mesh plots using functions like surf, plot3, and mesh along with an example mesh plot of a sinc function.
The document outlines various statistical and data analysis techniques that can be performed in R including importing data, data visualization, correlation and regression, and provides code examples for functions to conduct t-tests, ANOVA, PCA, clustering, time series analysis, and producing publication-quality output. It also reviews basic R syntax and functions for computing summary statistics, transforming data, and performing vector and matrix operations.
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxagnesdcarey33086
SAMPLE QUESTION:
Exercise 1: Consider the function
f (x,C)=
sin(C x)
Cx
(a) Create a vector x with 100 elements from -3*pi to 3*pi. Write f as an inline or anonymous function
and generate the vectors y1 = f(x,C1), y2 = f(x,C2) and y3 = f(x,C3), where C1 = 1, C2 = 2 and
C3 = 3. Make sure you suppress the output of x and y's vectors. Plot the function f (for the three
C's above), name the axis, give a title to the plot and include a legend to identify the plots. Add a
grid to the plot.
(b) Without using inline or anonymous functions write a function+function structure m-file that does
the same job as in part (a)
SAMPLE LAB WRITEUP:
MAT 275 MATLAB LAB 1 NAME: __________________________
LAB DAY and TIME:______________
Instructor: _______________________
Exercise 1
(a)
x = linspace(-3*pi,3*pi); % generating x vector - default value for number
% of pts linspace is 100
f= @(x,C) sin(C*x)./(C*x) % C will be just a constant, no need for ".*"
C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands
y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % supressing the y's
plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers for
% black and white plots
xlabel('x'), ylabel('y') % labeling the axis
title('f(x,C) = sin(Cx)/(Cx)') % adding a title
legend('C = 1','C = 2','C = 3') % adding a legend
grid on
Command window output:
f =
@(x,C)sin(C*x)./(C*x)
C1 =
1
C2 =
2
C3 =
3
(b)
M-file of structure function+function
function ex1
x = linspace(-3*pi,3*pi); % generating x vector - default value for number
% of pts linspace is 100
C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands
y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % function f is defined below
plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers for
% black and white plots
xlabel('x'), ylabel('y') % labeling the axis
title('f(x,C) = sin(Cx)/(Cx)') % adding a title
legend('C = 1','C = 2','C = 3') % adding a legend
grid on
end
function y = f(x,C)
y = sin(C*x)./(C*x);
end
Command window output:
C1 =
1
C2 =
2
C3 =
3
Joe Bob
Mon lab: 4:30-6:50
Lab 3
Exercise 1
(a) Create function M-file for banded LU factorization
function [L,U] = luband(A,p)
% LUBAND Banded LU factorization
% Adaptation to LUFACT
% Input:
% A diagonally dominant square matrix
% Output:
% L,U unit lower triangular and upper triangular such that LU=A
n = length(A);
L = eye(n); % ones on diagonal
% Gaussian Elimination
for j = 1:n-1
a = min(j+p.
The name MATLAB stands for MATrix LABoratory.MATLAB is a high-performance language for technical computing.
It integrates computation, visualization, and programming environment. Furthermore, MATLAB is a modern programming language environment: it has sophisticated data structures, contains built-in editing and debugging tools, and supports object-oriented programming.
These factor make MATLAB an excellent tool for teaching and research.
The document discusses various types of plots that can be created in MATLAB, including:
1. Standard two-dimensional plots created using the plot command, which connects data points with lines. Additional lines and graphs can be added to the same plot using hold on/off or the line command.
2. Plots with logarithmic axes created using semilogy, semilogx, and loglog for situations where data spans a wide range of values.
3. Formatted plots where elements like titles, labels, legends, grids can be added using various commands.
4. Specialized plots like bar plots, stem plots, and pie charts for different data visualization needs.
5. The ability to place
The document discusses various raster algorithms including raster displays, monitor intensities, RGB colour, line drawing, and simple anti-aliasing. It provides details on how raster displays work by representing images as a grid of pixels stored in a frame buffer and scanned line by line on the screen. It also describes how monitor intensities are represented digitally and processed, the RGB color model, algorithms for line drawing including DDA and Bresenham's, and different methods for simple anti-aliasing like supersampling.
statistical computation using R- an intro..Kamarudheen KV
This presentation deals with some basics of R language. It is very useful for benners in R. It describes the basics in a very easy manner, so those who are not familiar with R it would be very helpful.
This document provides an introduction to using R and RStudio. It discusses installing R and RStudio, the four windows in RStudio (source editor, console, environment/history, and plots/files), and basic commands and functions for running code, saving scripts, clearing the screen, commenting lines, and getting help. It also covers creating and manipulating variables and vectors, importing and exporting data, generating basic plots like bar plots, pie charts and histograms, and importing/exporting data.
More instructions for the lab write-up1) You are not obli.docxgilpinleeanna
More instructions for the lab write-up:
1) You are not obligated to use the 'diary' function. It was presented only for you convenience. You
should be copying and pasting your code, plots, and results into some sort of "Word" type editor that
will allow you to import graphs and such. Make sure you always include the commands to generate
what is been asked and include the outputs (from command window and plots), unless the problem
says to suppress it.
2) Edit this document: there should be no code or MATLAB commands that do not pertain to the
exercises you are presenting in your final submission. For each exercise, only the relevant code that
performs the task should be included. Do not include error messages. So once you have determined
either the command line instructions or the appropriate script file that will perform the task you are
given for the exercise, you should only include that and the associated output. Copy/paste these into
your final submission document followed by the output (including plots) that these MATLAB
instructions generate.
3) All code, output and plots for an exercise are to be grouped together. Do not put them in appendix, at
the end of the writeup, etc. In particular, put any mfiles you write BEFORE you first call them.
Each exercise, as well as the part of the exercises, is to be clearly demarked. Do not blend them all
together into some sort of composition style paper, complimentary to this: do NOT double space.
You can have spacing that makes your lab report look nice, but do not double space sections of text
as you would in a literature paper.
4) You can suppress much of the MATLAB output. If you need to create a vector, "x = 0:0.1:10" for
example, for use, there is no need to include this as output in your writeup. Just make sure you
include whatever result you are asked to show. Plots also do not have to be a full, or even half page.
They just have to be large enough that the relevant structure can be seen.
5) Before you put down any code, plots, etc. answer whatever questions that the exercise asks first.
You will follow this with the results of your work that support your answer.
SAMPLE QUESTION:
Exercise 1: Consider the function
f (x,C)=
sin(C x)
Cx
(a) Create a vector x with 100 elements from -3*pi to 3*pi. Write f as an inline or anonymous function
and generate the vectors y1 = f(x,C1), y2 = f(x,C2) and y3 = f(x,C3), where C1 = 1, C2 = 2 and
C3 = 3. Make sure you suppress the output of x and y's vectors. Plot the function f (for the three
C's above), name the axis, give a title to the plot and include a legend to identify the plots. Add a
grid to the plot.
(b) Without using inline or anonymous functions write a function+function structure m-file that does
the same job as in part (a)
SAMPLE LAB WRITEUP:
MAT 275 MATLAB LAB 1 NAME: ...
This document discusses several algorithms for drawing lines in computer graphics, including their requirements, properties, and steps. It describes the digital differential analyzer (DDA) algorithm, which uses incremental differences between line endpoints to plot pixels along the line. Bresenham's line algorithm is also summarized, which uses integer calculations to determine pixel positions with good visual quality. A parallel line algorithm is mentioned that can partition line drawing computations across multiple processors to calculate pixel positions efficiently in parallel.
This document discusses several algorithms for drawing lines in computer graphics, including their requirements, properties, and steps. It describes the digital differential analyzer (DDA) algorithm, which uses incremental differences between line endpoints to plot pixels along the line. Bresenham's line algorithm is also summarized, which uses integer calculations to determine pixel positions with good visual quality. A parallel line algorithm is mentioned that can partition line drawing computations across multiple processors to calculate pixel positions efficiently in parallel.
Notebooks such as Jupyter give programming languages a level of interactivity approaching that of spreadsheets.
I present here an idea for a programming language specifically designed for an interactive environment similar to a notebook.
It aims to combining the power of a programming language with the usability of a spreadsheet.
Instead of free-form code, the user creates fields / columns, but these can be combined into tables and object classes.
By decoratively cycling through field elements, loops and other programming constructs can be created.
I give examples from classical computer science, machine learning and mathematical finance, specifically:
Nth Prime Number, 8 Queens, Poker Hand, Travelling Salesman, Linear Regression, VaR Attribution
Explanation on Tensorflow example -Deep mnist for expert홍배 김
you can find the exact and detailed network architecture of 'Deep mnist for expert' example of tensorflow's tutorial. I also added descriptions on the program for your better understanding.
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSIJNSA Journal
The smart irrigation system represents an innovative approach to optimize water usage in agricultural and landscaping practices. The integration of cutting-edge technologies, including sensors, actuators, and data analysis, empowers this system to provide accurate monitoring and control of irrigation processes by leveraging real-time environmental conditions. The main objective of a smart irrigation system is to optimize water efficiency, minimize expenses, and foster the adoption of sustainable water management methods. This paper conducts a systematic risk assessment by exploring the key components/assets and their functionalities in the smart irrigation system. The crucial role of sensors in gathering data on soil moisture, weather patterns, and plant well-being is emphasized in this system. These sensors enable intelligent decision-making in irrigation scheduling and water distribution, leading to enhanced water efficiency and sustainable water management practices. Actuators enable automated control of irrigation devices, ensuring precise and targeted water delivery to plants. Additionally, the paper addresses the potential threat and vulnerabilities associated with smart irrigation systems. It discusses limitations of the system, such as power constraints and computational capabilities, and calculates the potential security risks. The paper suggests possible risk treatment methods for effective secure system operation. In conclusion, the paper emphasizes the significant benefits of implementing smart irrigation systems, including improved water conservation, increased crop yield, and reduced environmental impact. Additionally, based on the security analysis conducted, the paper recommends the implementation of countermeasures and security approaches to address vulnerabilities and ensure the integrity and reliability of the system. By incorporating these measures, smart irrigation technology can revolutionize water management practices in agriculture, promoting sustainability, resource efficiency, and safeguarding against potential security threats.
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesChristina Lin
Traditionally, dealing with real-time data pipelines has involved significant overhead, even for straightforward tasks like data transformation or masking. However, in this talk, we’ll venture into the dynamic realm of WebAssembly (WASM) and discover how it can revolutionize the creation of stateless streaming pipelines within a Kafka (Redpanda) broker. These pipelines are adept at managing low-latency, high-data-volume scenarios.
ACEP Magazine edition 4th launched on 05.06.2024Rahul
This document provides information about the third edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
Literature Review Basics and Understanding Reference Management.pptxDr Ramhari Poudyal
Three-day training on academic research focuses on analytical tools at United Technical College, supported by the University Grant Commission, Nepal. 24-26 May 2024
Understanding Inductive Bias in Machine LearningSUTEJAS
This presentation explores the concept of inductive bias in machine learning. It explains how algorithms come with built-in assumptions and preferences that guide the learning process. You'll learn about the different types of inductive bias and how they can impact the performance and generalizability of machine learning models.
The presentation also covers the positive and negative aspects of inductive bias, along with strategies for mitigating potential drawbacks. We'll explore examples of how bias manifests in algorithms like neural networks and decision trees.
By understanding inductive bias, you can gain valuable insights into how machine learning models work and make informed decisions when building and deploying them.
Low power architecture of logic gates using adiabatic techniquesnooriasukmaningtyas
The growing significance of portable systems to limit power consumption in ultra-large-scale-integration chips of very high density, has recently led to rapid and inventive progresses in low-power design. The most effective technique is adiabatic logic circuit design in energy-efficient hardware. This paper presents two adiabatic approaches for the design of low power circuits, modified positive feedback adiabatic logic (modified PFAL) and the other is direct current diode based positive feedback adiabatic logic (DC-DB PFAL). Logic gates are the preliminary components in any digital circuit design. By improving the performance of basic gates, one can improvise the whole system performance. In this paper proposed circuit design of the low power architecture of OR/NOR, AND/NAND, and XOR/XNOR gates are presented using the said approaches and their results are analyzed for powerdissipation, delay, power-delay-product and rise time and compared with the other adiabatic techniques along with the conventional complementary metal oxide semiconductor (CMOS) designs reported in the literature. It has been found that the designs with DC-DB PFAL technique outperform with the percentage improvement of 65% for NOR gate and 7% for NAND gate and 34% for XNOR gate over the modified PFAL techniques at 10 MHz respectively.
International Conference on NLP, Artificial Intelligence, Machine Learning an...gerogepatton
International Conference on NLP, Artificial Intelligence, Machine Learning and Applications (NLAIM 2024) offers a premier global platform for exchanging insights and findings in the theory, methodology, and applications of NLP, Artificial Intelligence, Machine Learning, and their applications. The conference seeks substantial contributions across all key domains of NLP, Artificial Intelligence, Machine Learning, and their practical applications, aiming to foster both theoretical advancements and real-world implementations. With a focus on facilitating collaboration between researchers and practitioners from academia and industry, the conference serves as a nexus for sharing the latest developments in the field.
2. MATLAB
Topics Covered:
1. Plotting basic 2-D plots.
The plot command.
The fplot command.
Plotting multiple graphs in the same plot.
Formatting plots.
Two Dimensional Plots
2
3. MAKING X-Y PLOTS
MATLAB has many functions and commands that can be used to
create various types of plots.
In our class we will only create two dimensional x – y plots.
3
4. Plotting
𝑠 = 2 sin 3𝑡 + 2 + 15𝑡 − 7
4
t 0 1 2 3 4 5
s -5.18 6.08 24.97 36 54.98 66.07
5. 8 10 12 14 16 18 20 22 24
0
200
400
600
800
1000
1200
DISTANCE (cm)
INTENSITY
(lux)
Light Intensity as a Function of Distance
Comparison between theory and experiment.
Theory
Experiment
Plot title
y axis
label
x axis
label
Text
Tick-mark label
EXAMPLE OF A 2-D PLOT
Data symbol
Legend
Tick-mark
5
6. TWO-DIMENSIONAL plot() COMMAND
where x is a vector (one dimensional array), and y is a vector.
Both vectors must have the same number of elements.
The plot command creates a single curve with the x values on
the abscissa (horizontal axis) and the y values on the ordinate
(vertical axis).
The curve is made from segments of lines that connect the
points that are defined by the x and y coordinates of the
elements in the two vectors.
The basic 2-D plot command is:
plot(x,y)
6
7. If data is given, the information is entered as the elements of the
vectors x and y.
If the values of y are determined by a function from the values
of x, than a vector x is created first, and then the values of y
are calculated for each value of x. The spacing (difference)
between the elements of x must be such that the plotted curve
will show the details of the function.
CREATING THE X AND Y VECTORS
7
8. PLOT OF GIVEN DATA
Given data:
>> x=[1 2 3 5 7 7.5 8 10];
>> y=[2 6.5 7 7 5.5 4 6 8];
>> plot(x,y)
A plot can be created by the commands shown below. This can be
done in the Command Window, or by writing and then running a
script file.
Once the plot command is executed, the Figure Window opens with
the following plot.
x
y
1 2 3 5 7 7.5 8
6.5 7 7 5.5 4 6 8
10
2
8
10. LINE SPECIFIERS IN THE plot() COMMAND
Line specifiers can be added in the plot command to:
Specify the style of the line.
Specify the color of the line.
Specify the type of the markers (if markers are desired).
plot(x,y,’line specifiers’)
10
11. LINE SPECIFIERS IN THE plot() COMMAND
Line Specifier Line Specifier Marker Specifier
Style Color Type
Solid - red r plus sign +
dotted : green g circle o
dashed -- blue b asterisk *
dash-dot -. Cyan c point .
magenta m square s
yellow y diamond d
black k
plot(x,y,‘line specifiers’)
11
12. LINE SPECIFIERS IN THE plot() COMMAND
The specifiers are typed inside the plot() command as strings.
Within the string the specifiers can be typed in any order.
The specifiers are optional. This means that none, one, two, or
all the three can be included in a command.
EXAMPLES:
plot(x,y) A solid blue line connects the points with no markers.
plot(x,y,’r’) A solid red line connects the points with no markers.
plot(x,y,’--y’) A yellow dashed line connects the points.
plot(x,y,’*’) The points are marked with * (no line between the
points.)
plot(x,y,’g:d’) A green dotted line connects the points which are
marked with diamond markers.
12
13. Year
Sales (M)
1988 1989 1990 1991 1992 1993 1994
127 130 136 145 158 178 211
PLOT OF GIVEN DATA USING LINE
SPECIFIERS IN THE plot() COMMAND
>> year = [1988:1:1994];
>> sales = [127, 130, 136, 145, 158, 178, 211];
>> plot(year,sales,'--r*')
Line Specifiers:
dashed red line and
asterisk markers.
13
14. PLOT OF GIVEN DATA USING LINE
SPECIFIERS IN THE plot() COMMAND
Dashed red line and
asterisk markers.
14
15. % A script file that creates a plot of
% the function: 3.5^(-0.5x)*cos(6x)
x = [-2:0.01:4];
y = 3.5.^(-0.5*x).*cos(6*x);
plot(x,y)
CREATING A PLOT OF A FUNCTION
Consider: 4
2
for
)
6
cos(
5
.
3 5
.
0
x
x
y x
A script file for plotting the function is:
Creating a vector with spacing of 0.01.
Calculating a value of y
for each x.
Once the plot command is executed, the Figure Window opens with
the following plot.
15
16. A PLOT OF A FUNCTION
4
2
for
)
6
cos(
5
.
3 5
.
0
x
x
y x
16
17. CREATING A PLOT OF A FUNCTION
If the vector x is created with large spacing, the graph is not accurate.
Below is the previous plot with spacing of 0.3.
x = [-2:0.3:4];
y = 3.5.^(-0.5*x).*cos(6*x);
plot(x,y)
17
18. THE fplot COMMAND
fplot(‘function’,limits)
The fplot command can be used to plot a function
with the form: y = f(x)
The function is typed in as a string.
The limits is a vector with the domain of x, and optionally with limits
of the y axis:
[xmin,xmax] or [xmin,xmax,ymin,ymax]
Line specifiers can be added.
18
19. PLOT OF A FUNCTION WITH THE fplot() COMMAND
>> fplot('x^2 + 4 * sin(2*x) - 1')
3
3
for
1
)
2
sin(
4
2
x
x
x
y
A plot of:
19
20. PLOTTING MULTIPLE GRAPHS IN THE SAME PLOT
Two methods:
1. Using the plot command.
2. Using the hold on, hold off commands.
20
21. USING THE plot() COMMAND TO PLOT
MULTIPLE GRAPHS IN THE SAME PLOT
Plots three graphs in the same plot:
y versus x, v versus u, and h versus t.
By default, MATLAB makes the curves in different colors.
Additional curves can be added.
The curves can have a specific style by adding specifiers after
each pair, for example:
plot(x,y,u,v,t,h)
plot(x,y,’-b’,u,v,’—r’,t,h,’g:’)
21
22. USING THE plot() COMMAND TO PLOT
MULTIPLE GRAPHS IN THE SAME PLOT
4
2
x
Plot of the function, and its first and second
derivatives, for , all in the same plot.
10
26
3 3
x
x
y
4
2
x
x = [-2:0.01:4];
y = 3*x.^3-26*x+6;
yd = 9*x.^2-26;
ydd = 18*x;
plot(x,y,'-b',x,yd,'--r',x,ydd,':k')
vector x with the domain of the function.
Vector y with the function value at each x.
4
2
x
Vector yd with values of the first derivative.
Vector ydd with values of the second derivative.
Create three graphs, y vs. x (solid blue
line), yd vs. x (dashed red line), and ydd
vs. x (dotted black line) in the same figure.
22
23. -2 -1 0 1 2 3 4
-40
-20
0
20
40
60
80
100
120
USING THE plot() COMMAND TO PLOT
MULTIPLE GRAPHS IN THE SAME PLOT
23
24. hold on Holds the current plot and all axis properties so that
subsequent plot commands add to the existing plot.
hold off Returns to the default mode whereby plot commands
erase the previous plots and reset all axis properties
before drawing new plots.
USING THE hold on, hold off, COMMANDS
TO PLOT MULTIPLE GRAPHS IN THE SAME PLOT
This method is useful when all the information (vectors) used for
the plotting is not available a the same time.
24
25. Plot of the function, and its first and second
derivatives, for all in the same plot.
10
26
3 3
x
x
y
4
2
x
x = [-2:0.01:4];
y = 3*x.^3-26*x+6;
yd = 9*x.^2-26;
ydd = 18*x;
plot(x,y,'-b')
hold on
plot(x,yd,'--r')
plot(x,ydd,':k')
hold off
Two more graphs are created.
First graph is created.
USING THE hold on, hold off, COMMANDS
TO PLOT MULTIPLE GRAPHS IN THE SAME PLOT
25
26. 8 10 12 14 16 18 20 22 24
0
200
400
600
800
1000
1200
DISTANCE (cm)
INTENSITY
(lux)
Light Intensity as a Function of Distance
Comparison between theory and experiment.
Theory
Experiment
Plot title
y axis
label
x axis
label
Text
EXAMPLE OF A FORMATTED 2-D PLOT
Data symbol
Legend
Tick-mark
Tick-mark label
26
27. FORMATTING PLOTS
A plot can be formatted to have a required appearance.
With formatting you can:
Add title to the plot.
Add labels to axes.
Change range of the axes.
Add legend.
Add text blocks.
Add grid.
27
28. FORMATTING PLOTS
There are two methods to format a plot:
1. Formatting commands.
In this method commands, that make changes or additions to
the plot, are entered after the plot() command. This can be
done in the Command Window, or as part of a program in a
script file.
2. Formatting the plot interactively in the Figure Window.
In this method the plot is formatted by clicking on the plot and
using the menu to make changes or add details.
28
29. FORMATTING COMMANDS
title(‘fuctions’)
Adds the string as a title at the top of the plot.
xlabel(‘string’)
Adds the string as a label to the x-axis.
ylabel(‘string’)
Adds the string as a label to the y-axis.
axis([xmin xmax ymin ymax])
Sets the minimum and maximum limits of the x- and y-axes.
29
30. FORMATTING COMMANDS
legend(‘string1’,’string2’,’string3’)
Creates a legend using the strings to label various curves (when
several curves are in one plot). The location of the legend is
specified by the mouse.
text(x,y,’string’)
Places the string (text) on the plot at coordinate x,y relative to
the plot axes.
gtext(‘string’)
Places the string (text) on the plot. When the command
executes the figure window pops and the text location is clicked
with the mouse.
30
31. FORMATTING Example
123
x = [10: 0.1: 22];
y = 95000 ./ x .^ 2;
x_data = [10: 2: 22];
y_data = [950 640 460 340 250 180 140];
plot(x, y, '-', x_data, y_data, 'ro--')
xlabel('DISTANCE (cm)')
ylabel('INTENSITY (lux)')
title('Light Intensity as a Function of Distance')
axis( [8 24 0 1200] )
legend('Theory', 'Experiment')
The plot that is obtained is shown again in the next slide.
Labels for the axes
Title of the plot
Set limits of the axes
Create legend
31
34. FORMATTING A PLOT IN THE FIGURE WINDOW
Once a figure window is open, the figure can be formatted interactively.
Use Figure,
Axes, and
Current Object-
Properties in
the Edit menu
Click here to start the
plot edit mode.
Use the insert menu to
34
35. PLOTTING MULTIPLE PLOTS ON ONE PAGE
Several plots on one page can be created with the subplot command.
subplot(m,n,p) This command creates mxn plots in the Figure
Window. The plots are arranged in m rows and n
columns. The variable p defines which plot is active.
The plots are numbered from 1 to mxn. The upper left
plot is 1 and the lower right plot is mxn. The numbers
increase from left to right within a row, from the first
row to the last.
35
36. PLOTTING MULTIPLE PLOTS ON ONE PAGE
subplot(3,2,1) subplot(3,2,2)
subplot(3,2,3)
subplot(3,2,5)
subplot(3,2,4)
subplot(3,2,6)
For example, the
command:
subplot(3,2,p)
Creates 6 plots
arranged in 3 rows
and 2 columns.
36
37. EXAMPLE OF MULTIPLE PLOTS ON ONE PAGE
The script file of the figure above is shown in the next slide.
37
38. % Example of using the subplot command.
x1=20:100; % Creating a vector x1
y1=sin(x1); % Calculating y1
subplot(2,3,1) % Creating the first plot
plot(x1,y1) % Plotting the first plot
axis([0 20 -2 2]) % Formatting the first plot
text(2,1.5,'A plot of sin(x)')
y2=sin(x1).^2; % Calculating y2
subplot(2,3,2) % Creating the second plot
plot(x1,y2) % Plotting the second plot
axis([0 20 -2 2]) % Formatting the second plot
text(2,1.5,'A plot of sin^2(x)')
y3=sin(x1).^3; % Calculating y2
SCRIPT FILE OF MULTIPLE PLOTS ON ONE PAGE
(The file continues on the next slide)
38
39. subplot(2,3,3) % Creating the third plot
plot(x1,y3) % Plotting the third plot
axis([0 20 -2 2]) % Formatting the third plot
text(2,1.5,'A plot of sin^3(x)')
subplot(2,3,4) % Creating the fourth plot
fplot('abs(sin(x))',[0 20 -2 2]) % Plotting the fourth plot
text(1,1.5,'A plot of abs(sin(x))') % Formatting the fourth plot
subplot(2,3,5) % Creating the fifth plot
fplot('sin(x/2)',[0 20 -2 2]) % Plotting the fifth plot
text(1,1.5,'A plot of sin(x/2)') % Formatting the fifth plot
subplot(2,3,6) % Creating the sixth plot
fplot('sin(x.^1.4)',[0 20 -2 2]) % Plotting the fifth plot
text(1,1.5,'A plot of sin(x^1^.^2)') % Formatting the sixth plot
SCRIPT FILE OF MULTIPLE PLOTS ON ONE PAGE
(CONT,)
39
40. Area Plot
• In the Area plotting graph, you can use basic functions. It is a
very easy draw.
• In the MATLAB plotting, there is a function
area() to plot Area.
% To create the area plot for the given equation Sin(t)Cos(2t). %
Enter the value of range of variable 't'.
t=[0:0.2:20];
a=[sin(t).*cos(2.*t)];
area(a)
title('Area Plot')
40
42. Stem Plot
• In Stem plot, the discrete sequence data and variables are
used. This plot is created by using the stem() function.
% Consider the variable range of 'x' and 'y',
x=[3 1 6 7 10 9 11 13 15 17];
y=[14 7 23 11 8 16 9 3 23 17];
stem(x,y,'r')
title('Stem Plot')
xlabel('X axis')
ylabel('Y axis')
42
44. Bar Plot
• A bar plot or bar chart is a graph that represents the category
of data with rectangular bars with lengths and heights that is
proportional to the values which they represent.
x=[1 3 5 7 10 13 15];
y=[0 0.5 1 1.5 3 2 2];
bar(x,y)
title('Bar Plot')
xlabel('X axis')
ylabel('y axis')
44
46. Barh Plot
• Barh plot is short abbreviations of Horizontal bar. Here I am
using the Barh function for the horizontal plane.
x=[1 3 5 7 10 13 15];
y=[0 0.5 1 1.5 3 2 2];
barh(x,y)
title('Barh Plot')
xlabel('X axis')
ylabel('y axis')
46
48. Stairs Plot
• This is again one of the MATLAB 2D plots that look more like
stairs.
x=[0 1 2 4 5 7 8];
y=[1 3 4 6 8 12 13];
stairs(x,y)
title('Stairs Plot')
xlabel('X axis')
ylabel('Y axis')
48
52. Scatter Plot
• A scatter plot (aka scatter chart, scatter graph) uses dots to
represent values for two different numeric variables. The
position of each dot on the horizontal and vertical axis
indicates values for an individual data point. Scatter plots are
used to observe relationships between variables.
x=[1 2 3 5 7 9 11 13 15];
y=[1.2 3 4 2.5 3 5.5 4 6 7];
scatter(x,y,'g')
title('Scatter Plot')
xlabel('X axis')
ylabel('Y axis')
52
54. Solving Basic Algebraic Equations in
MATLAB
• The solve function is used for solving algebraic
equations. In its simplest form, the solve
function takes the equation enclosed in
quotes as an argument.
• For example, let us solve for x in the equation
x-5 = 0
solve('x-5=0') or
y = solve('x-5 = 0') or
solve('x-5')
54
55. • If the equation involves multiple symbols, then
MATLAB by default assumes that you are solving
for x
• The solve function has another form −
solve(equation, variable)
where, you can also mention the variable.
• For example, let us solve the equation
v – u – 3t2 = 0, for v.
In this case, we should write −
solve('v-u-3*t^2=0', ‘v')
55
56. Solving Quadratic Equations in
MATLAB
• The solve function can also solve higher order equations. It
is often used to solve quadratic equations. The function
returns the roots of the equation in an array.
• The following example solves the quadratic equation x2 -7x
+12 = 0.
eq = 'x^2 -7*x + 12 = 0';
s = solve(eq);
disp('The first root is: ');
disp(s(1));
disp('The second root is: '),
disp(s(2));
56
57. • When you run the file, it displays the following
result −
The first root is:
3
The second root is:
4
57
58. Solving System of Equations in
MATLAB
• The solve function can also be used to generate solutions of
systems of equations involving more than one variables.
• Let us solve the equations −
5x + 9y+3z = 5
3x – 6y+7y = 4
• Create a script file and type the following code −
s = solve('5*x + 9*y = 5','3*x - 6*y = 4‘);
s.x
s.y
When you run the file, it displays the following result −
ans = 22/19
ans = -5/57
58
59. Polynomials
• MATLAB represents polynomials as row
vectors containing coefficients ordered by
descending powers. For example, the
equation P(x) = x4 + 7x3 - 5x + 9 could be
represented as −
p = [1 7 0 -5 9];
59
60. Evaluating Polynomials
• The polyval function is used for evaluating a
polynomial at a specified value. For example,
to evaluate our previous polynomial p, at x =
4, type −
p = [1 7 0 -5 9];
polyval(p,25)
60
61. • MATLAB also provides the polyvalm function
for evaluating a matrix polynomial. A matrix
polynomial is a polynomial with matrices as
variables.
• For example, let us create a square matrix X
and evaluate the polynomial p, at X −
p = [1 7 0 -5 9];
X = [1 2 -3 4; 2 -5 6 3; 3 1 0 2; 5 -7 3 8];
polyvalm(p, X)
61
62. Finding the Roots of Polynomials
• The roots function calculates the roots of a
polynomial. For example, to calculate the
roots of our polynomial p, type −
p = [1 7 0 -5 9];
r = roots(p)
62
63. MATLAB - Transforms
• MATLAB provides command for working with
transforms, such as the Laplace and Fourier
transforms.
• Transforms are used in science and engineering
as a tool for simplifying analysis and look at data
from another angle.
• The Fourier transform allows us to convert a
signal represented as a function of time to a
function of frequency. Laplace transform allows
us to convert a differential equation to an
algebraic equation.
63
64. • MATLAB provides the laplace, fourier and fft
commands to work with Laplace, Fourier and
Fast Fourier transforms.
64
65. The Laplace Transform
• The Laplace transform of a function of time f(t) is given by the
following integral −
• Laplace transform is also denoted as transform of f(t) to F(s). You
can see this transform or integration process converts f(t), a
function of the symbolic variable t, into another function F(s), with
another variable s.
• Laplace transform turns differential equations into algebraic ones.
To compute a Laplace transform of a function f(t), write −
laplace(f(t))
65
66. • In this example, we will compute the Laplace transform of
some commonly used functions.
• Create a script file and type the following code −
syms s t a b w
laplace(a)
laplace(t^2)
laplace(t^9)
laplace(exp(-b*t))
laplace(sin(w*t))
laplace(cos(w*t))
66
67. The Inverse Laplace Transform
• MATLAB allows us to compute the inverse
Laplace transform using the command
ilaplace.
• For example,
ilaplace(1/s^3)
67
68. Fourier Transform
• Fourier transforms commonly transforms a
mathematical function of time, f(t), into a new
function, sometimes denoted by or F, whose
argument is frequency with units of cycles/s
(hertz) or radians per second. The new
function is then known as the Fourier
transform and/or the frequency spectrum of
the function f.
68
69. • create a script file and type the following code in it −
syms x
f = exp(-2*x^2); %our function
ezplot(f,[-2,2]) % plot of our function
frt= fourier(exp(-2*x^2)) % Fourier transform
69
70. • The following result is displayed −
frt= (2^(1/2)*pi^(1/2)*exp(-w^2/8))/2
ezplot(ftr)
70
71. Inverse Fourier Transforms
• MATLAB provides the ifourier command for
computing the inverse Fourier transform of a
function. For example,
f = ifourier(-2*exp(-abs(w)))
• MATLAB will execute the above statement and
display the result −
f = -2/(pi*(x^2 + 1))
71
72. MATLAB - Differential
• MATLAB provides the diff command for
computing symbolic derivatives. In its simplest
form, you pass the function you want to
differentiate to diff command as an argument.
• compute the derivative of the function f(t) =
3t2 + 2t-2
syms t
f = 3*t^2 + 2*t^(-2);
diff(f)
72
73. syms x
syms t
f = (x + 2)*(x^2 + 3)
der1 = diff(f)
f = (t^2 + 3)*(sqrt(t) + t^3)
der2 = diff(f)
f = (x^2 - 2*x + 1)*(3*x^3 - 5*x^2 + 2)
der3 = diff(f)
f = (2*x^2 + 3*x)/(x^3 + 1)
der4 = diff(f)
f = (x^2 + 1)^17
der5 = diff(f)
f = (t^3 + 3* t^2 + 5*t -9)^(-6)
der6 = diff(f)
73
74. Computing Higher Order Derivatives
• To compute higher derivatives of a function f,
we use the syntax diff(f,n).
• Let us compute the second derivative of the
function y = f(x) = x .e-3x
f = x*exp(-3*x);
diff(f, 2)
74
75. • let us solve a problem. Given that a function y = f(x) = 3 sin(x) + 7
cos(5x). We will have to find out whether the equation f" + f = -
5cos(2x) holds true.
syms x
y = 3*sin(x)+7*cos(5*x); % defining the function
lhs = diff(y,2)+y; %evaluting the lhs of the equation
rhs = -5*cos(2*x); %rhs of the equation
if(isequal(lhs,rhs))
disp('Yes, the equation holds true');
else disp('No, the equation does not hold true');
End
disp('Value of LHS is: ');
disp(lhs);
75