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

Triple the fundamental frequency, For the signal with four harmonics (first...

For the signal with four harmonics (first to fourth) that can be obtained from the script, do the following: a)  Place the time domain signal for the case in which all the harmo

Regression, can we use regression in bioinformatics toolbox?

can we use regression in bioinformatics toolbox?

Calculate the signal-to-noise ratio, Use the MATLAB randn function to gener...

Use the MATLAB randn function to generate 1000 points for x. Generate the output of the unknown system with the ?lter function and b=[1232 1] and a=[1]. Normalise the ?lter output

Convolution, Perform the convolution of following sequences (a) x[n] = [1 2...

Perform the convolution of following sequences (a) x[n] = [1 2 3], N1 = 1 and h[n] = [1 - 1], N2 = 1 (b) x[n] = [1 2 3], N1 = 2 and h[n] = [1 - 1], N2 = 1 (c) x[n] = [1 2 3], N1 =

Determine an expression for the transfer function, The circuit diagram of a...

The circuit diagram of an active filter is shown below. (a) Determine an expression for the transfer function of the filter. (b) Hence find an expression for the frequency res

Numerical integration methods, The fundamental theorem of calculus states t...

The fundamental theorem of calculus states that the de?nite integral of a function may be found from the antiderivative of the function. However, for many functions, it is much eas

Rc phase shift oscillater, design a rc phase shift oscillator for a particu...

design a rc phase shift oscillator for a particular frequency of oscillation and generate a sinusoidal signal

CPM AND PERT, ACTIVITIES OF A PROJECT 1-2 1-3 1-4 1-5 2-6 3-6 3-7 4-7 5-7 7...

ACTIVITIES OF A PROJECT 1-2 1-3 1-4 1-5 2-6 3-6 3-7 4-7 5-7 7-6 6-8 7-8 THE COMMPANY LOSES 2,000 FOR EVERY WEEK THE PROJECT LASTS BEYOND 30 WEEKS. fOR EACH OF THE PROPOSALS; ACTIVI

Matlab code using ant colony algorithm, Ant Colony Optimization for Optimiz...

Ant Colony Optimization for Optimization of Route path taken Ant Colony Algorithm is a potential candidate for coupled, 3D optimisation. Ant Colony Algorithm enjoys the overall

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