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

Example of hold and legend function, Example of Hold and legend function: ...

Example of Hold and legend function: Running this script will generate two individual figure windows. If there is not any other active figure window, the first, that is the ba

Calculate sample mean and standard deviation, Make a vector of 500 random n...

Make a vector of 500 random numbers from a normal distribution with mean 2 and standard deviation 5(randn). a After you generate the vector, verify that the sample mean and stan

Programs to determine discrete fourier transform, A 12-point sequence is x ...

A 12-point sequence is x (n) defined as x(n) = { 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1}. Write MATLAB programs to (a) Determine the DFT X (k) of x(n) and plot (using stem function)

Wireless, can i getting wirless programing in matlab

can i getting wirless programing in matlab

Polynomial fitting, how can i used loops instead of polyfit function

how can i used loops instead of polyfit function

Digging the dirt - autonomous mining robots , Digging the Dirt: Autonomous...

Digging the Dirt: Autonomous Mining Robots   Mining is a multi-billion dollar industry and a critical part of the Australian economy. Much of the day-to-day work on mining sites

Robot, How to simulate a robot

How to simulate a robot

Variable numbers of arguments, Variable numbers of arguments: In the f...

Variable numbers of arguments: In the functions there have been a fixed number of input and output arguments. For illustration, in the function below, there is one input argum

Recognizing people in video based on their body", I am doing project "Recog...

I am doing project "Recognizing people in video based on their body" the system will use MATLAB to detect people based on thier body and then recognize them from their clothes "us

Speech recognition using support vector machine, what are data collect th...

what are data collect this topic,how i can create algorithm in mat lab what language support easy to this topic

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