Big Chemical Encyclopedia

Chemical substances, components, reactions, process design ...

Articles Figures Tables About

Matlab function files

It can be synthesized with the MATLAB function feedback (). As an illustration, we will use a simple first order function for Gp and Gm, and a PI controller for Gc. When all is done, we test the dynamic response with a unit step change in the reference. To make the reading easier, we break the task up into steps. Generally, we would put the transfer function statements inside an M-file and define the values of the gains and time constants outside in the workspace. [Pg.241]

We note that fzerotryl is a MATLAB function m file that is stored in its folder with the extension. m as fzerotryl.m. Our program code is annotated with comments following the % symbol. Anything that follows after a % symbol on a line of code is not executed in MATLAB. More on MATLAB files, their storage, creation, etc. is given in Section 1.2.5. Specific built-in MATLAB functions and their use, such as fzero in the code below, should always be scrutinized by our students for their input/output syntax etc. using the built-in help MATLAB command help fzero for example. [Pg.27]

The code above is a MATLAB function m file with two inputs xstaxt and k and one output X. Its first code line... [Pg.31]

Modify the MATLAB function m file newtonpoly9.m on p. 30 to print out three columns of iterates with their iteration indices for all values of k. [Pg.33]

MATLAB m and Other Files and Built-in MATLAB Functions... [Pg.43]

In the previous sections we have used MATLAB commands that were typed in on the desktop command line, as well as MATLAB commands that invoke special stored MATLAB files, called m files. When starting to work with MATLAB, we advise our users to create a special folder for their personal MATLAB m files once and to continue to use this folder to store personal m files. To access the stored m files from the MATLAB desktop, the user has to point the small desktop window called Current Directory to the personal m file folder. Then all stored m files, as well as all built in MATLAB functions can be accessed, called upon, and used from the command line. All stored personal... [Pg.43]

MATLAB m files can contain any number of MATLAB commands. They are handy for long sets of MATLAB instructions or data and afford easy repeated use and easy modification. There are two kinds of MATLAB m files function and script m files. Script m files such as poly9. m on p. 28 use the data that is defined inside of them and any undefined data is taken from the data (with the proper name) that is currently active on the workspace look at the top left window commonly displayed on the MATLAB desktop for a list of defined variables and their type. Script files overwrite the workspace data as instructed in their code. [Pg.44]

The reader should study our earlier MATLAB m files now, such as the script m file poly9. m on p. 28 and the function m file fzerotryl. m on p. 27 and look for their differences. [Pg.45]

Creates a function handle, so that functions can be passed to MATLAB function m files as variables are. [Pg.47]

Note that almost all calling sequences of MATLAB function m files start with the function s name, such as runsolveadiabxy above, followed by a list of parameters in parentheses (. .. ). Our particular call runsolveadiabxy(285,305,1,8.5) uses the interval limits 285 and 305 for a as its first two parameters, followed by the values of / and 7 for a specific chemical reaction. In our m files the list of possible parameters is always explained in the first comment lines of code. Often one or several of the parameters are optional. If they are not specified in the calling sequence, they are internally set to default values inside the program, such as n and anno are here. [Pg.75]

Our CD also contains the MATLAB function m file runNadiabNisokccurve. m. A call of runNadiabNisokccurve (180000,1,15,1,100,. 001, .7,1.2), for example, plots only the bifurcation curve with respect to Kc in Figure 3.16, i.e., it repeats the bottom plot in Figure 3.14. [Pg.102]

Using the MATLAB function called re anal.m, calculate values for each column shown in Table 4.1. Use the sample data file called pea dat . Use the results to make and interpret plots of the eigenvalues and Malinowski s RE and REV functions. [Pg.95]

The mathematical model of FCC feed optimization described in section 9.2.3 was programmed in MATLAB model-files where the various constraints were formulated as objective components in the hard form. Applying the duality principle, the various maximization objectives were converted to minimization functions by simply negating them (Dantzig and Thapa, 1997 Deb, 2001). These model files were linked to the MOEA Toolbox to obtain the optimized values for the various control variables. LP was also applied and its solutions were used as a basis for comparison. [Pg.288]

Within the function file, we define if as such in the first line. The set of ordinary equations Reactor is written as a function of the independent variable, t, and a vector of dependent variables x. In order to use variable names closer to the real ones, we can define fhem as columns of fhe dependent variables vector (i.e., I = x(l)). Next, in the second line, we write the global statement so that these variables can be used within the script. MATLAB needs that all the parameters, constants, or equations are explicit of the variables and defined before fhe system of differential equations. Thus, we write the rate constants and other parameters defined earlier. This reactor is a semibatch in the sense that we add the initiator during the first minute of the reaction at a constant rate. Thus, we define a rafe that is constant if the time is lower or equal to 60 s and 0 otherwise using the if-then-end syntax. Finally, we write the differential equations. The right-hand side of the differential equations must be the same word as the one we use in the title of the function Reactor. Each equation will be Reactor (n, 1). We present the results in Figure 4.17. [Pg.133]

Now that we have the model developed, we implement it in MATLAB. We create a script to write the ode statement. In this script, we also include the statement for plotting the results. The ode statement includes the function React, the range of the independent variable, in this case the weight of catalyst, and finally the initial values for the variables involved, the concentration of SOj, the temperature, and the pressure. In the function file, we write the model developed earlier including... [Pg.142]

It is also of interest to determine the LU factorization of this A matrix. The MATLAB file lua.m (Figure 2.7) can be run after running the file lin2-2.m to determine its triangular factorization. Note that we have first used the help facility to learn specific details on the MATLAB function lu. [Pg.64]

The following MATLAB m-file establishes the right-hand side function of the unconstrained truck model after dividing by the masses and torques. [Pg.271]

It is desirable to simplify the fifth-order model, say, to a first-order model. Equation (26.6) is used as a minimization criterion and the code for the exercise is given in file F2602.m. The MATLAB function finincon is used to perform the search for the optimum model parameters. Since the MATLAB function idpoly is used to construct the detailed model, Eqn. (26.11) is written in the following form ... [Pg.351]

A function file is a user-defined function using MATLAB. We use function files for repetitive tasks. The first line of a function file must contain the word function, followed by the output argument, the equal sign (=), function name, and the input argument enclosed in parentheses. The function name and file name must be the same, but the file name must have the extension. m. For example, the function file consisting of the following two lines... [Pg.81]

The first line defines the function xpowers, which has two outputs sq and cube and one input. The second line is a comment statement that is used to tell what xpowers is all about. The third and fourth lines calculate the values of input squared and cubed, respectively. While the main MATLAB window is active, press CTRL+N to activate the MATLAB m-file editor and paste the previous four lines. Save the file as xpowers.m. [Pg.82]

Figure 10.47 shows a portion of the pop-up optimtool Window, in which the user inputs the type of solver to be used by MATLAB the solver (choose fmincon) the algorithm (choose Active set) the objective function file (choose a handle to objecfun function) the derivatives (choose Approximated... [Pg.339]

Figure 10.47 A portion of optimtool Window in which the user decides on the type of solver and algorithm to be used by MATLAB, the objective function file the start point vector, the lower and upper bound vectors the nonlinear constraint function and finally the derivative evaluation method. Figure 10.47 A portion of optimtool Window in which the user decides on the type of solver and algorithm to be used by MATLAB, the objective function file the start point vector, the lower and upper bound vectors the nonlinear constraint function and finally the derivative evaluation method.
There are two types of m-files, functions and scripts. A MATLAB function has variables that can be passed into and out of the function. Any other variables used inside the function are not saved in memory when the function is finished. Scripts, on the other hand, save all their variables in the MATLAB workspace. Functions and scripts have names like myfunction.m. The first line of a function must contain a function declaration, using the following format ... [Pg.493]

Commented lines immediately following the function declaration comprise the help file for the function. To obtain information on any function, simply type help function. Some MATLAB functions that are useful for process control include ... [Pg.493]

MATLAB has its own built-in function fzero for root finding. The statement fzero file nam jc, ) finds the root of the function/(x) introduced in the user-defined MATLAB function The second argument jt , is a starting guess. Starting with... [Pg.8]

MATLAB does not even bother wit a Routh function. Such an M-file is provided on our Web... [Pg.127]

Note 2 The iterative solution in solving the ultimate frequency is tricky. The equation has poor numerical properties—arising from the fact that tan9 "jumps" from infinity at 9 = (ir/2) to negative infinity at 9 = (ir/2)+. To better see why, use MATLAB to make a plot of the function (LHS of the equation) with 9 < co < 1. With MATLAB, we can solve the equation with the f zero () function. Create an M-file named f. m, and enter these two statements in it ... [Pg.132]

The Wegstein method is a secant method applied to g(x) = x - Fix). In Microsoft Excel, roots are found by using Goal Seek or Solver. Assign one cell to be x, put the equation for/(x) in another cell, and let Goal Seek or Solver find the value of x that makes the equation cell zero. In MATLAB, the process is similar except that a function (m-file) is defined and the command fzeroCf .xO) provides the solution x, starting from the initial guess xO. [Pg.44]

This function is called numerous times from the Matlab ODE solver. In the example it is the ode45 which is the standard Runge-Kutta algorithm. ode45 requires as parameters the file name of the inner function, ode autocat. m, the vector of initial concentrations, cO, the rate constants, k, and the total amount of time for which the reaction should be modelled (20 time units in the example). The solver returns the vector t at which the concentrations were calculated and the concentrations themselves, the matrix C. Note that due to the adaptive step size control, the concentrations are computed at times t which are not predefined. [Pg.88]

A script m file in MATLAB does not start with a function. . . declaration as the function m file fzerotryl. m does. A script m file rather consists only of MATLAB commands. See Section 1.2.5 for more details on these two types of m files in MATLAB. [Pg.29]

If this function m file is stored as f unct. m in the current desktop working directory, it can be called and executed in MATLAB by typing funct(3,5,17) or x=3 z=5 k=17 [yy.sign] = f unct (x, z, k) for example. These calls will create the following sequence of outputs. [Pg.44]

The fundamental difficulty in solving DEs explicitly via finite formulas is tied to the fact that antiderivatives are known for only very few functions / M —> M. One can always differentiate (via the product, quotient, or chain rule) an explicitly given function f(x) quite easily, but finding an antiderivative function F with F x) = f(x) is impossible for all except very few functions /. Numerical approximations of antiderivatives can, however, be found in the form of a table of values (rather than a functional expression) numerically by a multitude of integration methods such as collected in the ode... m file suite inside MATLAB. Some of these numerical methods have been used for several centuries, while the algorithms for stiff DEs are just a few decades old. These codes are... [Pg.533]

Using the MATLAB sva function, calculate the row-mode and columnmode eigenvectors, U and V, for the sample data file called pca daf . Make plots of the first four row-mode and column-mode eigenvectors. [Pg.95]


See other pages where Matlab function files is mentioned: [Pg.8]    [Pg.8]    [Pg.40]    [Pg.422]    [Pg.259]    [Pg.77]    [Pg.350]    [Pg.74]    [Pg.489]    [Pg.146]    [Pg.539]    [Pg.5]    [Pg.221]    [Pg.31]    [Pg.287]    [Pg.456]   
See also in sourсe #XX -- [ Pg.468 ]




SEARCH



MATLAB

MATLAB functions

MATLAB functions M-file

© 2024 chempedia.info