Plotting Functions of Two Variables:
Functions on Rectangular Grids:
Presume you wish to plot a function f(x, y) on the rectangle a ≤ x ≤ b and c ≤ y ≤ d. The graph of the function of two variables is of course a three dimensional object. Visualizing the graph is habitually very useful.
For instance presume you have a formula:
f(x, y) = x sin(xy)
And you are involved in the function on the region 0 ≤ x ≤ 5, π ≤ y ≤ 2π. A manner to plot this function in Mat lab would be the following sequence of commands
> f = inline(’x.*sin(x.*y)’,’x’,’y’)> [X,Y] = meshgrid(0:.1:5,pi:.01*pi:2*pi);> Z = f(X,Y)>mesh(X,Y,Z)
This will produce a 3-D plot that you are able to rotate by clicking on the rotate icon and then dragging with the mouse.
Instead of the command mesh you could utilize the command:
>surf(X,Y,Z)
The key command in this series is [X Y] = meshgrid(a:h:b,c:k:d) which generates matrices of x and y values in X and Y. Enter
>size(X)>size(Y)>size(Z)
to see that each one of these variables is a 101 × 51 matrix. To observe the first few entries of X enter
>X(1:6,1:6)
And to see the first several values of Y type
>Y(1:6,1:6)
You must observe that the x values in X begin at 0 on the left column and increase from left to right. The y values on the other have begun at π at the top and increase from top to bottom. Note down that this arrangement is flipped from the typical arrangement in the x-y plane.
In the command [X Y] = meshgrid(a:h:b,c:k:d) h is the increase in the x direction and k is the increment in the y direction.
Habitually we will calculate:
h = (b – a) m and k = (d − c) n
Where m is the number of intervals in the x direction as well as n is the number of intervals in the y direction. To acquire a good plot it is best if m and n can be set between 10 and 100.
For another illustration of how meshgrid works try the following and look at the output in X andY.
> [X,Y] = meshgrid(0:.5:4,1:.2:2);
Scattered Data and Triangulation:
Habitually we are interested in objects whose bases are not rectangular. For instance, data does not typically come arranged in a nice rectangular grid rather measurements are occupied where convenient.
In Mat lab we are able to produce triangles for a region by recording the coordinates of the vertices and recording which vertices belong to each triangle. The subsequent script program produces such a set of triangles:
% mytriangles% Program to produce a triangulation.% V contains vertices, which are (x,y) pairsV = [ 1/2 1/2 ; 1 1 ; 3/2 1/2 ; .5 1.5 ; 0 01 0 ; 2 0 ; 2 1 ; 1.5 1.5 ; 1 20 2 ; 0 1]% x, y are row vectors containing coordinates of verticesx = V(:,1)’;y = V(:,2)’;% Assign the trianglesT = delaunay(x,y)
You are able to plot the triangles using the following command
>trimesh(T,x,y)
You can as well prescribe values (heights) at each vertex directly (say from a survey):
> z1 = [ 2 3 2.5 2 1 1 .5 1.5 1.6 1.7 .9 .5 ];
Or by means of a function:
> f = inline(’abs(sin(x.*y)).^(3/2)’,’x’,’y’);> z2 = f(x,y);
The resulting profiles are able to be plotted:
>trimesh(T,x,y,z1)>trisurf(T,x,y,z2)
Every row of the matrix T corresponds to a triangle so T(i) gives triangle number i. The 3 corners of triangle number i are at indices T(i,1), T(i,2), and T(i,3). Therefore for example to get the y-coordinate of the second point of triangle number 5 enter
>y(T(5,2))
To see other illustration of regions defined by triangle get mywedge.m and mywasher.m from the class web site as well as run them. Every of these programs defines vectors x and y of x and y values of vertices and a matrix T. As prior to T is a list of sets of three integers. Every triple of integers indicates which vertices to connect in a triangle.
To plot a function say f(x, y) = x2 − y2 on the washer figure try
>mywasher> z = x.^2 - y.^2>trisurf(T,x,y,z)
Note again that this plot is able to be rotated using the icon and mouse.
Latest technology based Matlab Programming Online Tutoring Assistance
Tutors, at the www.tutorsglobe.com, take pledge to provide full satisfaction and assurance in Matlab Programming help via online tutoring. Students are getting 100% satisfaction by online tutors across the globe. Here you can get homework help for Matlab Programming, project ideas and tutorials. We provide email based Matlab Programming help. You can join us to ask queries 24x7 with live, experienced and qualified online tutors specialized in Matlab Programming. Through Online Tutoring, you would be able to complete your homework or assignments at your home. Tutors at the TutorsGlobe are committed to provide the best quality online tutoring assistance for Matlab Programming Homework help and assignment help services. They use their experience, as they have solved thousands of the Matlab Programming assignments, which may help you to solve your complex issues of Matlab Programming. TutorsGlobe assure for the best quality compliance to your homework. Compromise with quality is not in our dictionary. If we feel that we are not able to provide the homework help as per the deadline or given instruction by the student, we refund the money of the student without any delay.
tutorsglobe.com structure of a virus assignment help-homework help by online viruses tutors
Avail the paramount Macroeconomics Assignment Help service by the qualified Ph.D. tutors and secure top grades today at fair prices.
Theory and lecture notes of Exception Handling all along with the key concepts of exception handling, transaction management. Tutorsglobe offers homework help, assignment help and tutor’s assistance on Exception Handling.
Preparation of Alkanes and cycloalkanes tutorial all along with the key concepts of Wurtz reaction, Kolbe's electrolytic method, Hydrogenation of Unsaturated Hydrocarbons, Reduction of Alkyl Halides, Decarboxylation of Carboxylic Acids, Preparation of Cycloalkanes, Nitration, Isomerisation
tutorsglobe.com kinds of budget assignment help-homework help by online budget tutors
Bacteria tutorial all along with the key concepts of Features of Bacteria, Size and shape of Bacteria, Nutrition in Bacteria, Respiration in Bacteria, Reproduction in Bacteria and Beneficial Activities of Bacteria
www.tutorsglobe.com offers linear programming assignment help, linear programming homework help and problems solutions with step by step answers by operation research tutors.
Measurement of Temperature tutorial all along with the key concepts of Heat and Temperature, Types of Temperature Scales, Conversion Formulas, Constant Volume Gas Thermometer Scale, Standard Thermometer Scale, Types of Thermometer and Optical Pyrometers
Theory and lecture notes of Determinant of a Square Matrix all along with the key concepts of Elementary Row Operations, Triangular Matrices, Larger Order Determinants, Inverse of a Matrix, Cofactors, Matrix of Minors, Minors. Tutorsglobe offers homework help, assignment help and tutor’s assistance on Determinant of a Square Matrix.
get notable content and round the clock support with top-rated meteorology assignment help service and score a++!
Dielectrics and Capacitors tutorial all along with the key concepts of Capacitance and Permittivity, Parallel Plate capacitor, Energy of a Charged Capacitor, Energy Density, Combination of Capacitors, Capacitors in Parallel, Capacitors in Series and Types of Capacitor
Gas Origin, Transportation and uses tutorial all along with the key concepts of Origin of Natural Gas Accumulations, Unconventional Gas Accumulations, Town Gas, Bio Gas, Hydrates, Natural Gas Production, Uses of Natural Gas, Power Generation and Environmental Effect-Natural gas
tutorsglobe.com periodic properties assignment help-homework help by online periodic table and its properties tutors
Theory and lecture notes of Equivalence of CFGs and NPDAs all along with the key concepts of equivalence of cfgs and npdas, Context Free Grammars & Languages, palindromes, Invariant. Tutorsglobe offers homework help, assignment help and tutor’s assistance on Equivalence of CFGs and NPDAs.
Avail the best qualified and experienced Canadian Politics Assignment Help tutors with 24/7 support to secure top grades.
1961875
Questions Asked
3689
Tutors
1489297
Questions Answered
Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!