Category Archive for: function and files

Using Global Variables

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…

Read More →

Optimization of an Irrigation Chanel

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…

Read More →

PROBLEMS

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…

Read More →

Working with Data Files

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,…

Read More →

Summary

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,…

Read More →

Advanced Function Programming

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…

Read More →

User-Defined Functions

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…

Read More →

Elementary Mathematical Functions

Elementary Mathematical Functions You can use the look for command to find functions that are relevant to your application. For example; type lookfor imaginary to get a list of the functions that deal with imaginary numbers. You will see listed:  imag Complex imaginary part  i       Imaginary unit ii       Imaginary unit Note that…

Read More →

Functions and Files

OUTLINE 3.1 Elementary Mathematical Functions 3.2 User-Defined Functions 3.3 Advanced Function Programming 3.4 .Working with Data Files 3.5 Summary Problems MATLAB has many built-in functions, including trigonometric, logarithmic, and hyperbolic functions, as well as functions for processing arrays.  these functions are summarized in Section 3.1. In addition, you can define your own  unctions with a…

Read More →

Back to Top