MATLAB_Online_Tutorial_corrected

# MATLAB_Online_Tutorial_corrected - CHEE 222 PROCESS...

This preview shows pages 1–2. Sign up to view the full content.

CHEE 222: PROCESS DYNAMICS AND NUMERICAL METHODS Prepared by Kunal Karan 1 Solving Nonlinear Equation(s) in MATLAB 1 Introduction This tutorial helps you use MATLAB to solve nonlinear algebraic equations of single or multiple variables. 2 Writing MATLAB functions In order to use the MATLAB solvers, you must first be able to write MATLAB functions. There are two different methods to create a function - (a) inline command, and (b) Matlab editor 2.1 The ‘ inline ’ command The inline command can be used for simple, one-line functions. For example, to create f ( x ) = x 3 - 5 x 2 -x + 2 : >> f = inline (‘ x^ 3 -5*x^2 - x + 2’) f = Inline function: f(x) = x^3-5*x^2-x+2 You can now evaluate the function value at any given x. For example, to evaluate the function value at x = 4, simply type ‘ f (4) ’ at Matlab command line. EDU>> f(4) ans = -18 2.2 The MATLAB editor The editor allows the user to write functions of any length and/or complexity. 1. Set the current working directory to your diskspace e.g. “c:\CHEE222\Matlab\Iamhappy\Temp\”

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

MATLAB_Online_Tutorial_corrected - CHEE 222 PROCESS...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online