# Category Archive for: function and files

Using Global Variables Engineers often need to estimate the pressures and volumes of a gas in a container. ideal gas law provides one way of making the estimate. The law is . RT I p = V More accurate estimates can be made with the van der Waals equation: RT a p= V -b V2 where the term b is a correction for…

Optimization of an Irrigation Chanel Figure 3.2-3 shows the cross section of an irrigation channel. A preliminary analysis has shown that the cross-sectional area of the channel should be 100ft2 to,carry the desired water-flow rate. To minimize the cost of concrete used to line’ the channel,we want to minimize the length of the channel’s perimeter. Find the…

Problems You can find the answers to problems marked with an asterisk at the end of the text. Section 3.1 1.* Suppose that y = – 3 +ix. For x =0, 1, and 2, use MATLAB to compute the following expressions. Hand check the answers. a.’ Iyl b. .JY\ c. (-5 -7i)y d·6 2. * Let x…

Working with Data Files A typical ASCII data file has one or more lines of text at the beginning. These might be comments that describe what the data represents, the date it was created, and who created the data, for example. These lines are called the header. One or more lines of data, arranged in rows and columns,…

Summary MATLAB supplies very many functions. In Section 3.1 we introduced just some of the most commonly used mathematical functions. You should now be able to use the MATLAB help to find other functions you need. If necessary, you can – create your own functions, using the methods of Section 3.2. Function handles, anonymous functions, subfunctions,…

Advanced Function Programming Since the introduction of function handles in MATLAB 6.0, their use has become quite widespread in the MATLAB documentation and elsewhere, and so it.is a good idea to become familiar with the concept. In addition, anonymous functions, subfunctions, and nested functions are also now seen more often In documentation and examples. This section covers the…

User-Defined Functions FUNCTION FILE Another type of M-file.is a function file. Unlike a script file, all the variables in a function file are local. which means their values are available only within the function. Function files are useful when you need to repeat a set of commands several times. Function files are like functions in C, subroutines in…