Simulating Gradient Contour and Mesh of a Scalar Field Usman Ali Khan, Bismah Tariq, Khalida Raza, Saima Malik, Aoun Muhammad

Similar documents
INTERNATIONAL EDITION. MATLAB for Engineers. Third Edition. Holly Moore

The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development

PROGRAMMING WITH MATLAB WEEK 6

3D plot of a surface in Matlab

Lab of COMP 406 Introduction of Matlab (II) Graphics and Visualization

Classes 7-8 (4 hours). Graphics in Matlab.

EGR 102 Introduction to Engineering Modeling. Lab 05B Plotting

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

MATLAB Laboratory 09/23/10 Lecture. Chapters 5 and 9: Plotting

Mechanical Engineering Department Second Year (2015)

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

An Introduction to the Directional Derivative and the Gradient Math Insight

GRAPHICS AND VISUALISATION WITH MATLAB

Logical Subscripting: This kind of subscripting can be done in one step by specifying the logical operation as the subscripting expression.

Basic Graphs. Dmitry Adamskiy 16 November 2011

This module aims to introduce Precalculus high school students to the basic capabilities of Matlab by using functions. Matlab will be used in

MATH 2221A Mathematics Laboratory II

Matlab Tutorial 1: Working with variables, arrays, and plotting

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations

Computation of Slope

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

Engineering Geology. Engineering Geology is backbone of civil engineering. Topographic Maps. Eng. Iqbal Marie

Graphics in MATLAB. Responsible teacher: Anatoliy Malyarenko. November 10, Abstract. Basic Plotting Commands

Scalar Visualization

More on Plots. Dmitry Adamskiy 30 Nov 2011

MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations)

What is Matlab? A software environment for interactive numerical computations

Dr. Iyad Jafar. Adapted from the publisher slides

Experimental and Computational Investigation of Flow Distortion Around a Tubular Meteorological Mast

MATLAB basic guide to create 2D and 3D Plots. Part I Introduction

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

Math Sciences Computing Center. University ofwashington. September, Fundamentals Making Plots Printing and Saving Graphs...

2. AREAL PHOTOGRAPHS, SATELLITE IMAGES, & TOPOGRAPHIC MAPS

MAT 275 Laboratory 3 Numerical Solutions by Euler and Improved Euler Methods (scalar equations)

TikZ & PGF(plots) Daniel Knittl-Frank. May This work is licensed under the Creative Commons Attribution-ShareAlike 3.

Chapter 2. MATLAB Fundamentals

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

Chapter 11. Above: Principal contraction rates calculated from GPS velocities. Visualized using MATLAB.

A very brief Matlab introduction

Introduction to MATLAB: Graphics

1. Register an account on: using your Oxford address

Scalar Visualization

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens.

Modeling & Simulation of Supersonic Flow Using McCormack s Technique

PyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as

What is a Topographic Map?

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?

Goals: Course Unit: Describing Moving Objects Different Ways of Representing Functions Vector-valued Functions, or Parametric Curves

Lecture overview. Visualisatie BMT. Fundamental algorithms. Visualization pipeline. Structural classification - 1. Structural classification - 2

Introduction to Matlab for Engineers

EOSC 352 MATLAB Review

INC151 Electrical Engineering Software Practice. MATLAB Graphics. Dr.Wanchak Lenwari :Control System and Instrumentation Engineering, KMUTT 1

Chapter 2 Surfer Tutorial

NENS 230 Assignment 4: Data Visualization

QUICK INTRODUCTION TO MATLAB PART I

Torsional-lateral buckling large displacement analysis with a simple beam using Abaqus 6.10

W1005 Intro to CS and Programming in MATLAB. Plo9ng & Visualiza?on. Fall 2014 Instructor: Ilia Vovsha. hgp://

Purpose: To explore the raster grid and vector map element concepts in GIS.

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University

fraction of Nyquist

FF505/FY505 Computational Science. MATLAB Graphics. Marco Chiarandini

Overview. Lecture 13: Graphics and Visualisation. Graphics & Visualisation 2D plotting. Graphics and visualisation of data in Matlab

Overview for Families

Surfaces and Partial Derivatives

Matlab Practice Sessions

Worksheet 2.1: Introduction to Multivariate Functions (Functions of Two or More Independent Variables)

MATLAB Tutorial III Variables, Files, Advanced Plotting

MATLAB Modul 3. Introduction

Dr Richard Greenaway

Mathematics. Geometry Revision Notes for Higher Tier

MATLAB Tutorial. Primary Author: Shoumik Chatterjee Secondary Author: Dr. Chuan Li

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:

1. Which diagram best represents the location of the isolines for the elevation field of this landscape? (1) (2) (3) (4)

CFD modelling of thickened tailings Final project report

Surface Smoothing Using Kriging

DATA PLOTTING WITH MATLAB

PyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as

Plotting - Practice session

ME422 Mechanical Control Systems Matlab/Simulink Hints and Tips

Preview. Two-Dimensional Motion and Vectors Section 1. Section 1 Introduction to Vectors. Section 2 Vector Operations. Section 3 Projectile Motion

Local Linearity (Tangent Plane) Unit #19 : Functions of Many Variables, and Vectors in R 2 and R 3

MATLAB Modul 2. Introduction to Computational Science: Modeling and Simulation for the Sciences, 2 nd Edition

Chapter - 2: Geometry and Line Generations

f for Directional Derivatives and Gradient The gradient vector is calculated using partial derivatives of the function f(x,y).

Fundamentals of Structural Geology Exercise: concepts from chapter 2

Understanding Topographic Maps

Question: What are the origins of the forces of magnetism (how are they produced/ generated)?

Practice to Informatics for Energy and Environment

Mat 241 Homework Set 7 Due Professor David Schultz

MATLAB Guide to Fibonacci Numbers

2D LINE PLOTS... 1 The plot() Command... 1 Labeling and Annotating Figures... 5 The subplot() Command... 7 The polarplot() Command...

Medical Image Processing using MATLAB

Unit #19 : Functions of Many Variables, and Vectors in R 2 and R 3

Unit #20 : Functions of Many Variables, and Vectors in R 2 and R 3

Contour Analysis And Visualization

Lesson 4: Gradient Vectors, Level Curves, Maximums/Minimums/Saddle Points

Analysis of different interpolation methods for uphole data using Surfer software

You can change the line style by adding some information in the plot command within single quotation marks.

Computing Fundamentals Plotting

Polarization Handedness Convention

Transcription:

Vol:5, No:8, 11 Simulating Gradient Contour and Mesh of a Scalar Field Usman Ali Khan, Bismah Tariq, Khalida Raza, Saima Malik, Aoun Muhammad International Science Index, Physical and Mathematical Sciences Vol:5, No:8, 11 waset.org/publication/1169 Abstract This research paper is based upon the simulation of gradient of mathematical functions and scalar fields using MATLAB. Scalar fields, their gradient, contours and mesh/surfaces are simulated using different related MATLAB tools and commands for convenient presentation and understanding. Different mathematical functions and scalar fields are examined here by taking their gradient, visualizing results in 3D with different color shadings and using other necessary relevant commands. In this way the outputs of required functions help us to analyze and understand in a better way as compared to just theoretical study of gradient. Keywords MATLAB, Gradient, Contour, Scalar Field, Mesh I. INTRODUCTION HE motive of this paper is to study about the gradient of Tscalar fields, its working and functionality and to have a look over its vast applications in different fields of life. For better understanding we took the help of MATLAB and its different commands to simulate gradient of different functions and scalar fields so that we can have a visual study of our topic.a brief introduction of term gradient tells us that it is a Latin word and refers to gradual change in any quantity. []The term gradient (grad) typically refers to the derivative of functions of more than one variable. Gradient of a scalar field is obtained by applying del operator on a scalar field expression, that gives the direction to that field in its increasing dimension, as illustrated by the picture below Fig. 1 Direction of gradient of field In this image, the scalar field is in black and pink, black representing higher values and its gradient is represented by the purple arrows. Using MATLAB we can draw the mesh or the surfaces of the gradient of the mathematical functions representing different scalar fields. For example the following image is the drawing of the function: z = x y. The different tools and commands executed to obtain this surface will be discussed later in the paper. Mr.Usman Ali Khan is with University college of Engineering and Technology UCET The Islamia University of Bahawalpur.. - - 3 Fig. Direction of gradient of field II. GRADIENT The gradient of a scalar field V is a vector that represents the magnitude and the direction of the greatest increase rate of V. Gradient is a vector (a direction to move) that points in the direction of greatest increase. [3]The gradient of any function or scalar field F can be given by following mathematical equation: gradf(x,y,z) = 5 F(x,y,z) = (df/dx,df/dy,df/dz) The gradient of an R 3 scalar field is an R 3 vector field. In - D the four-gradient is a vector, formed as a derivative of four scalars. The gradient can also be used to measure how a scalar field changes in other directions, rather than just the direction of greatest change, by taking a dot product. The gradient is zero at a point of maximum location because there is no further direction of increase, rather there is a decrease rate in any direction under consideration. It s just like standing on the top of a mountain and there is a downhill any direction you move. [5]Also the gradient of a vector or a vector field makes no sense and is meaningless because a vector quantity already has a predefined direction and cannot be given a second direction, i.e., a vector cannot have more than one direction. Above its complexity or convenience issues, gradient is tremendously useful and is applicable in most of the life matters and science. III. PRACTICAL APPLICATIONS Gradient can be applied in a large variety of studies such as Engineering field, biomedical field, Astrological fields, Atmospheric studies, etc. 15 5 International Scholarly and Scientific Research & Innovation 5(8) 11 1138 scholar.waset.org/137-689/1169

Vol:5, No:8, 11 International Science Index, Physical and Mathematical Sciences Vol:5, No:8, 11 waset.org/publication/1169 A. Gradient is used for the measurement of the steepness of a road and thus is very useful in civil engineering. Let a surface point at sea level (x,y) having a height H(x,y) so the gradient of H, basically a vector defining the direction of steepest slope at that point. And how much the steepness is defined by the magnitude of the gradient of vector H. B. Temperature gradient shows that the particular direction at which the rate of temperature changes rapidly around a specific direction. The temperature gradient is mostly used in the applications of atmospheric science, meteorology and climatology. C. Geothermal gradient is the rate of increasing temperature with respect to increasing depth in the Earth's interior. [6]It is 5 3 C per km of depth in most of the world. This is useful for generating power. D. In biomedical and biosensors, it is used to investigate the protein absorption and cell adhesion. It is also used in fundamental and applied material science studies such as generation of polymers. Fig. 3 Protein absorption cell E. Gradient also simplify the development of new analytical techniques, since allowing the testing of many different surfaces under the same environmental conditions, thus minimizing the experimental errors. F. Gradient also serves as the templates for the demixing of polymer blends IV. RELEVANT COMMANDS The term MATLAB stands for MATrix LABoratory. Therefore while working with MATLAB, both scalars and vectors are considered as in matrix form. Scalar corresponds to a single element, while a vector corresponds to a one dimensional matrix. The commands that are used in this report, to execute gradient of different scalar fields, are given below along with their functions performed. B. gradientm(); Its syntax is as follows; [aspect,slope,gradn,grade] = gradientm(map,refvec); This command is used to compute the slope, aspect, and north and east components of the gradient for a regular data grid. The visual percept of the gradient of the function or the field is mentioned by aspect command. If we have the surface map contains elevations in meter, then the results of aspect and slope shows the units of the degrees clockwise from north and up from the horizontal. The component of gradient regarding north and east represents the change in the map variable per meter of distance in the north and east direction 7. C. meshgrid(); Its syntax is as [X,Y] = meshgrid(x,y); and it is used to change the domain specified by vectors x and y into arrays X and Y, which can be used to evaluate functions of two variables and three-dimensional mesh/surface plots. [7]The rows of the output array X shows the copies of the vector columns of the output array Y are copies of the vector y. x=[ 6]; y=[5 6 7]; [X,Y]=meshgrid(x,y) X = 6 6 6 Y = 5 5 5 6 6 6 7 7 7 D. contour(); Its syntax is as contour(z); and it displays isolines of a matrix. [7]It will give the default number of contour levels depending upon the minimum and maximum values of Z. While the number of contour levels can be set according to the specifications by using contour(z,n) command, where n is the specified number of contour levels. z=x.*y; contour(z) 18 16 1 1 A. Gradient(); Its syntax is as [FX,FY] = gradient(f); and it is used to specify the maximum space rate of increase of a scalar field as told by its definition. 8 6 6 8 1 1 16 18 Fig. D Gradient International Scholarly and Scientific Research & Innovation 5(8) 11 1139 scholar.waset.org/137-689/1169

Vol:5, No:8, 11 International Science Index, Physical and Mathematical Sciences Vol:5, No:8, 11 waset.org/publication/1169 E. quiver(); Its syntax is as quiver(x,y,u,v); and it displays velocity vectors as arrows with components (u,v) at the points (x,y). The command quiver(,linespec) is used to change the colour and style of the velocity vectors. This style and colour is specified by the tool LineSpec. z=x.*y; contour(z) quiver(xx,yy) 18 16 1 1 8 6 6 8 1 1 16 18 Fig. 5 D Gradient by quiver command F. surf(); Its syntax is as: surf(x,y,z); and it is used to view mathematical functions over a rectangular region.surf and surfc create colored surfaces. The colour of the shaded surface can be changed by using surf(x,y,z,c) command, where c specifying the colour. z=x.*y; surf(z) 3 - - -3 3 Fig. 6 D Gradient by surf command 5 15 5 V. SIMULATING GRADIENT OF A SCALAR FUNCTION Some simple codes are discussed to illustrate the working of the commands discussed earlier. Almost similar codes are executed by varying one or more parameters in them, so that the varying outputs could be examined. A. Gradient of a scalar: The following code represents the gradient of the equation of a circle or a circular field. This code contains the simple commands to illustrate their working through a simple output shown. v=-:.:; z=x.^ + y.^; [px,py]=gradient(z,.5,.5); contour(v,v,z) quiver(v,v,px,py) xlabel( x ); ylabel( y ); title( Gradient of field z=x^+y^ ) Fig. 7 D Gradient of Scalar Circular Field at origin Here the center of the circular field is at the origin O(,) but we can also change its center from origin to anywhere we want in the required scenario. In case when it is required to shift the center of this circular field to height h, we made a little variation in the circle equation in the code, as follows: v=-:.:; h=1; [x,y]=meshgrid(v) z=(x-h).^ + (y-h).^ [px,py]=gradient(z,.5,.5) contour(v,v,z) quiver(v,v,px,py) xlabel('x'); ylabel('y') title('gradient of the field z=(x-h)^+(y-h)^') International Scholarly and Scientific Research & Innovation 5(8) 11 11 scholar.waset.org/137-689/1169

Vol:5, No:8, 11 c for cyan color, etc. But the MATLAB has limited colors and line styles. [x,y]=meshgrid(v) z=x+y [px,py]=gradient(z,.,.); contour(z,'-.r') quiver(px,py,'c') International Science Index, Physical and Mathematical Sciences Vol:5, No:8, 11 waset.org/publication/1169 Fig. 8 D Gradient of Scalar Circular Field at shifted origin Hence the center is shifted from origin to height h(1,1).similarly the center can be shifted to any height or depth from the origin by specifying the required height coordinates to the point h(a,b). Where a and b are the real numbers whose values can either be equal or different. B. 3-D Contours: This code represents the contours of the given function in 3-dimensional view by making use of contour3() command. v=-:.:; [x,y]=meshgrid(v) z=x.*exp(-x.^-y.^) [xx,yy]=gradient(z) contour3(z) quiver(xx,yy) C. LineSpec tool: In this code the colors and the line style of contours and quivers are changed by using the linespec tool as the following syntax; contour(,linespec) and quiver(,linespec) With the help of LineSpec tool, the line style can be changed to dashed line (--), or to the dotted line by using (:), or to the dash dot line style by using (-.).The color of line can also be changed by using the specified color coding words such as r for red, b for blue, m for magenta, 18 16 1 1 8 6 6 8 1 1 16 18 Fig. 3D contour vectors with line spacing In this code a dashed (--) line indicates contour and its colour is set to red using LineSpec tool. Similarly with the help of this tool, the cyan color lines indicates the quiver vectors. D. Mesh and Surface Drawings: This code tells about how to draw 3D views of mesh and surfaces of the mathematical functions or the fields. This code contains the command of shading(); to assign a colour to the drawn surface or the mesh. Variation could be made by varying shading command to give it different shades. v=-:.:; z=x.^ + y.^; mesh(z) quiver(xx,yy, r ) surf(z) shading interp Fig. 9 3D contour International Scholarly and Scientific Research & Innovation 5(8) 11 111 scholar.waset.org/137-689/1169

Vol:5, No:8, 11 - - 3 5 15 5 International Science Index, Physical and Mathematical Sciences Vol:5, No:8, 11 waset.org/publication/1169 Fig. 11 3D Mesh To examine the difference between the mesh() and surf()commands, we consider their graphs separately by using the subplot() command in the following code: v=-:.:; z=x.^ - y.^; subplot(1,3,1) mesh(z) quiver(xx,yy,'r') subplot(1,3,) surf(z) shading interp quiver(xx,yy,'m') Fig. 1 3D Mesh This figure represents the mesh(z) command, a net like hollow outline of function z = x - y. While red arrows represent the quiver or the direction of the gradient of z. Fig. 13 3D Mesh This image is the result of the surf(z) command which gives a solid surface of the function z = x y. And the magenta arrows are the direction of the gradient of z. E. Simulating Gradient using gradientm() command 7 : In this code we have used the MATLLAB peaks matrix and found out their gradient using gradient() command, so that we can also examine the east and north components of the gradient and also its slop and aspect 7. Peaks is a function of two variables, obtained by translating and scaling Gaussian distributions, and its syntax is; Z = peaks(n); that returns an n-by-n matrix, and Z is specifying the function using peaks matrix. If the order n of the matrix is not defined, then it will return a 9 x 9 matrix by default. In this code we have also made use of the worldmap(map,refvec,type) command that defines the geographical limits for the required data grid and that data grid is then displayed using the meshm() command. datagrid = 5*peaks(); gridrv = [ ]; [aspect,slope,grade] = gradientm(datagrid,gridrv); figure worldmap(grade,gridrv,'none') meshm(grade,gridrv,size(datagrid),datagrid) contourcmap(1,'jet','colorbar','on',... 'ylabelstring','gradient (East Component)'); view(3) daspectm meters camlight...1 E 3 1-1 Gradient (East Component).1 S - -3 Fig. 1 3D contour with camlight International Scholarly and Scientific Research & Innovation 5(8) 11 11 scholar.waset.org/137-689/1169

Vol:5, No:8, 11 This image shows east component of gradient.in the next part of the code, the slope of the gradient is displayed. clmo surface meshm(slope,gridrv,size(datagrid),datagrid) contourcmap(,'hot','colorbar','on',... 'ylabelstring','slope (degrees)') shading interp 36 33 3...1 E 7 18 15 1 Aspect (degrees) International Science Index, Physical and Mathematical Sciences Vol:5, No:8, 11 waset.org/publication/1169.1 S Fig. 15 3D contour with camlight and shading VI. CONCLUSION At the end of this paper, we can say for sure that gradient has a wide range of applications and uses in almost every field of life, listing industrial environments, professional and technical studies and biomedical fields, and it is serving the world of technicalities in a true sense.moreover with help of MATLAB, the complexities of gradient are made far convenient by using its numerous powerful commands and tools. REFERENCES [1] Matthew N. O. Sadiku, Elements of Electromagnetics, 3 rd ed. Section 3.5, Gradient of a Scalar. Oxford University Press, 1, pp. 56. [] Wilfred Kaplan, Advanced Calculus, th ed. Section 3.3, The Gradient Field. Addison-Wesley, 1991, pp. 15 165 [3] Schey, H. M. Div, Grad, Curl, and All That: An Informal Text on Vector Calculus, 3rd ed. New York: W. W. Norton, 1997,pp -6. [] N. von Ellenrieder, C. Muravchik, E. Spinelli, A. Nehoraiy, J. Roitmanz, W. Silvaz and S. Kochenz, Performance of the Electroencephalography Inverse Problem using the Electric Potential Gradient Measurements. IEEE 3.E. H. Miller, A note on reflector arrays (Periodical style Accepted for publication), IEEE Trans. Antennas Propagat., to be published. [5] Morse, P. M. and Feshbach, H. Methods of Theoretical Physics, Part I. New York: McGraw-Hill, 1953,ch-6,7 [6] David A. Rothstein, Craig E. Manning. Geothermal gradients in continental magmatic arcs: Constraints from the eastern Peninsular Ranges batholiths, Baja California, México, Geological society of America, USA 3. [7] Fundamental of Electromagnetics with MATLAB, by Karl.E.Lonngren and Sava V.Savov, Randay.J.Jost, nd ed. 7.M. Young, The Techincal Writers Handbook. Mill Valley, CA: University Science, 1989. 9 6 3 International Scholarly and Scientific Research & Innovation 5(8) 11 113 scholar.waset.org/137-689/1169