MATLAB Numerical Basics. Roots of Polynominals MATLAB can find all roots (both real and imaginary) of polynominals. Store coefficients in a vector v =

Slides:



Advertisements
Similar presentations
Real Gases. The ideal gas equation of state is not sufficient to describe the P,V, and T behaviour of most real gases. Most real gases depart from ideal.
Advertisements

Lecture 5.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
MATLAB Optimization Greg Reese, Ph.D Research Computing Support Group Miami University.
Chapter 5 Section 4: Complex Numbers. VOCABULARY Not all quadratics have real- number solutions. For instance, x 2 = -1 has no real-number solutions because.
Properties of Reservoir Fluids Fugacity and Equilibrium Fall 2010 Shahab Gerami 1.
An equation of state is a relation between state variables It is a thermodynamic equation describing the state of matter under a given set of physical.
Chapter 18 Ideal vs. Real Gases. Variables Affecting Gases 4 Variables: 1.Pressure 2.Volume 3.Temperature 4.Number of particles By changing any one of.
ENGG 1801 Engineering Computing MATLAB Lecture 2: Background for Week 4 Tutorial Simple Programming in MATLAB.
General Linear Least-Squares and Nonlinear Regression
Matlab Matlab is a powerful mathematical tool and this tutorial is intended to be an introduction to some of the functions that you might find useful.
Speed of Gases. Speed of Gases Root Mean Square Speed of Gases R = J *K / mol J = 1kg * m2 / s2 MM = molar mass.
Atkins’ Physical Chemistry Eighth Edition Chapter 1 The Properties of Gases Copyright © 2006 by Peter Atkins and Julio de Paula Peter Atkins Julio de Paula.
Real gases 1.4 Molecular interactions 1.5 The van de Waals equation 1.6 The principle of corresponding states Real gases do not obey the perfect gas law.
Real vs. Ideal Gas Under what types of pressure do gases behave ideally? Under what type of temperatures do gases behave ideally? We originally defined.
Chemistry 231 Real Gases. The ideal gas equation of state is not sufficient to describe the P,V, and T behaviour of most real gases. Most real gases depart.
Real Gases Deviation from ideal gas Law: -Gas particles have volume - Attraction exists between gas particles (liquefication) Ideal gas law applies only.
Introduction to programming in MATLAB MATLAB can be thought of as an super-powerful graphing calculator Remember the TI-83 from calculus? With many more.
M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files called M- files. M-files are.
Real gas 1.molecules not always in motion (condense phase can be formed) 2.molecular size is non-negligible (there is molecular repulsion) 3.Molecules.
Ideal Gas Law.
Part 2 Chapter 7 Optimization
Analytical vs. Numerical Minimization Each experimental data point, l, has an error, ε l, associated with it ‣ Difference between the experimentally measured.
Ideal Gas Law (Equation):
Gas Stoichiometry. Equal volumes of gases at the same temperature and pressure contain equal amounts of particles The coefficients in a balanced equation.
MATLAB Basics. The following screen will appear when you start up Matlab. All of the commands that will be discussed should be typed at the >> prompt.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Radicals without Calculators
Scientific Computing General Least Squares. Polynomial Least Squares Polynomial Least Squares: We assume that the class of functions is the class of all.
Gases and Their Properties Chapter 11. Gases Some common elements and compounds exist in the gaseous state under normal conditions of pressure and temperature.
Real Gases. The ideal gas equation of state is not sufficient to describe the P,V, and T behaviour of most real gases. Most real gases depart from ideal.
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
5.2 Ideal Gases Densities of gases  Sensitive to T and P P-V-T relation  Equation of State (EOS) Ideal Gas Law for Single Component PV = nRT Ideal Gas.
Copyright © 2011 Pearson Education, Inc. The Theory of Equations Section 3.3 Polynomial and Rational Functions.
Analyzing Functions (4.16) y=f(x) MATLAB. Functional Analysis includes: Plotting and evaluating a function Finding extreme points Finding the roots (zeros.
Newton’s Method, Root Finding with MATLAB and Excel
Root Mean Square Velocity (urms)
Section 2-4 Real Zeros of Polynomial Functions. Section 2-4 long division and the division algorithm the remainder and factor theorems reviewing the fundamental.
Energy Balance on Reactive Processes
More Functions in MATLAB. Functions that operate on other functions A function F() can take another function G() as an argument by using a notation:
Introduction to MATLAB Section2, statistics course Third year biomedical dept. Dina El Kholy, Ahmed Dalal.
Basis of Mathematical Modeling LECTURE 3 Numerical Analysis with MATLAB Dr. N.K. Sakhnenko, PhD, Professor Associate.
Recap Functions with No input OR No output Determining The Number of Input and Output Arguments Local Variables Global Variables Creating ToolBox of Functions.
Force between two neutral atoms. Van der Waals equation.
Section 3.4 – Zeros of a Polynomial. Find the zeros of 2, -3 (d.r), 1, -4.
First Semester Final Review Presentation.
ME 123 Computer Applications I Lecture 16: More Matlab Programming: Secant Method, Review 4/4/03.
Scientific Method. 1. Identify Problem Written as a question. No pronouns.
PreCalculus Section 1.6 Solve quadratic equations by: a. Factoring b. Completing the square c. Quadratic formula d. Programmed calculator Any equation.
Gas Laws Review. A sample of carbon dioxide occupies a volume of 3.5 L at 125 kPa pressure. What pressure would the gas exert if the volume was lowered.
Volume and Moles. Avogadro’s Law  When the number of moles of gas is doubled (at constant temperature and pressure, the volume doubles.  The volume.
Introduction to Programming on MATLAB Ecological Modeling Course Sep 11th, 2006.
Boyle’s Law The First Gas Law. Objectives Upon completion of this presentation, you will be able to describe the relationship between the pressure and.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 - Chapter 7 Optimization.
8.4 The Kinetic Molecular Theory and Real Gas Behavior.
REAL GAS RELATIONSHIPS How can we predict behavior of gases at such conditions ? There are FOUR methods: 1) Compressibility Charts 2) Equations of State.
Ideal Gas Law Van der Waals combined Boyle’s and Charles’ Laws.
The Ideal Gas Law Ideal Gas  Follows all gas laws under all conditions of temperature and pressure.  Follows all conditions of the Kinetic Molecular.
Section 2.5 – Quadratic Equations
PreCalculus Section 1. 6 Solve quadratic equations by: a. Factoring b
Section 6.5 Theorems about Roots of Polynomial Equations Objective: Students will be able to solve equations using Theorems involving roots. Rational Root.
4.2 Real Zeros Finding the real zeros of a polynomial f(x) is the same as solving the related polynomial equation, f(x) = 0. Zero, solution, root.
Gas Laws Name Period Due Date.
Chapter 7: Optimization
General Linear Least-Squares and Nonlinear Regression
Applications of User Defined functions in MATLAB
Basic Chemistry Chapter 11 Gases Chapter 11 Lecture
Section 2.4: Real Zeros of Polynomial Functions
U12-6 Unit 12 Warm-Up – 05/01 Write the equation for the Combined Gas Law. What variable is held constant when using this law? Rearrange the Combined Gas.
Part 2 Chapter 7 Optimization
Presentation transcript:

MATLAB Numerical Basics

Roots of Polynominals MATLAB can find all roots (both real and imaginary) of polynominals. Store coefficients in a vector v = [ a 1 a 2 … a n a n+1 ]. Use roots builtin function with vector as argument. Return value is a vector containing all n roots of the polynominal

>> roots( [ ] ) ans =

Roots of Functions MATLAB can find a single root for any function for which a MATLAB function file can be written. One of the builtin methods for doing this is fzero. approx_root ) fname is the name of the function for which a root is to be located. It can have only one argument, the function’s variable. approx_root is an initial guess for the value of the root.

Van der Waals Equation P = Pressure ( 10 atm ) T = Temperature ( 250°K ) R = Gas Constant ( liter-atm/gmole-°K ) V = Specific Volume ( liter/gmole ) Ammonia a = 4.19 atm (liter/gmole) 2 b = liter/gmole

Minimums MATLAB has builtin procedures to find minimums in functions. This is an important tool in optimizations. One such tool is fminbnd. It finds the minimum of a MATLAB function between two bounds. x1, x2 ) fname is the name of the MATLAB function to be optimized. This function has one argument, the independent variable, and must be written to accept vector arguments. x1 is the lower bound of the minimum x2 is the upper bound of the minimum

Minimize x 3 -17x + 12 between 0 and 10 m-file simple.m: function y = simple( x ) y = x.^3 -17*x + 12; >> 0, 10) ans =

Global Variables Normally variables in functions are local only to that function. Many times one would like to define constants to be used in several functions or be able to change the value of a variable in a function without editing the function. This would be useful for instance in changing the temperature or pressure in a VDW calculation. The global statement in MATLAB allows variables to be shared. The global statement must be used in each MATALB area where the sharing is to occur. The global statement must be executed before the variable is used. Gilat, Section 6.3