Functions with local variables, MATLAB Programming

Assignment Help:

Functions with Local Variables:

The functions we have seen faraway have been very easy. Though, in many situations the computations in a function are more complex, and may need the use of extra variables within the function; these are known as local variables.

For illustration, a closed cylinder is being constructed of a material which costs a dollar amount per square foot. We will write a function which will compute and return the cost of the material, rounded up to the nearby square foot, for a cylinder with a certain radius and a certain height. The total surface area for the closed cylinder is

SA = 2πrh + 2πr2

For illustration, for a cylinder with radius of 32 inches and height 73 inches, and the cost per square foot of material is $4.50, the computation would be given by the algorithm shown below:

(A) Compute the surface area SA = 2*π * 32 * 73 + 2 * π * 32 * 32 inches squared

(B) Compute the SA in square feet = SA/144

(C) Compute the total cost = SA in square feet * cost per square foot

The function involves local variables to store the intermediate results.

1712_Functions with local variables.png


Related Discussions:- Functions with local variables

Characters and encoding, Characters and Encoding: A character in a MAT...

Characters and Encoding: A character in a MATLAB is represented by using single quotes (example, 'a' or 'x'). The quotes are essential to denote a character; without them, the

Implement the methods in matlab, The Requirement details of project are as ...

The Requirement details of project are as below. I also need detail description for presentation. For the project, given the training dataset ticdata2000.txt use any method you

Extraction, i want to extract an image from its background in matlab..the i...

i want to extract an image from its background in matlab..the image is a binary image

How to open simpower, How to Open Simpower: 1. Open MATLAB 2. ...

How to Open Simpower: 1. Open MATLAB 2. In the "Command Window" write ' simulink ' and press Enter or click on the Simulink icon. 3. Simulink Library Browser w

Draw the histogram of the original image, Given the following image, ...

Given the following image, 1 2 1 1 2 0 0 1 5 1 0 1

Appending data to a data file, Appending data to a data File: A text f...

Appending data to a data File: A text file once exists; the data can be appended to it. The format is similar as formerly, with the addition of the qualifier -append. For illu

Introduction to handle graphics, In this lab, we implement vectors, script ...

In this lab, we implement vectors, script and functions with plot. Plot function is used to plot the point into graph. These plots are handled by handle (h).  These handle is used

Find the total per phase inductance and per phase shunt, A 300 km, 3-phase,...

A 300 km, 3-phase, 50Hz transmission line has spacing as shown in Figure 2. Each phase of the line consists of a bundle of three conductors.  (a) Find the total per-phase induct

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd