4. An enclosure composed of a rectangular portion and a semicircular portion is to be enclosed by a fence (solid line/curve). As described in more detail below, you will write a program that determines the cost of fence for the enclosure. Note that the cost per foot CostC for the curved portion of fence is greater than the cost Costs for the straight portion. a. Write a function FenceCost that will accept as input arguments values of the total enclosure Area, the radius dimension R, and the costs per foot CostC and Costs for the curves and straight fencing, respectively, and will return as output argument the total cost of fence. (Hint: write an equation for Area and use it to determine a value for L based on the inputs.) Test your function by verifying that it gives a result of $2181 for the following input values: Area = 3000 ft2, R = 20 ft, CostC = $12 per foot, CostS-= $9 per foot. b. Write a script (program) that uses a nested for loop structure and fprintf to print a table of fence costs for R values ranging from 10 to 40 ft in steps of 5, and Area values ranging from 2500 to 3500 ft2 in steps of 100. (Use CostC = $12ft and CostS¬ = $9/ft as before.) Call the function with scalar values of R and Area to calculate each fence cost; do NOT use any arrays in this program. c. Write a script that instead uses a "vectorized" approach, making use of the meshgrid function, to calculate all of the same fence cost values above without using any loops, but still using the FenceCost function to perform the calculation. In this case, display the fence cost values in a properly-labelled 3D plot rather than in a table. d. Write a script that prompts the user for the enclosure area, and then determines and outputs the minimum total fence cost, along with the corresponding enclosure dimensions R and L. Use the fencing costs per foot CostC and Costs from part (a) above. Test your program for a user input of Area = 3000 ft2. (Hint: use fminbnd on a function handle that uses FenceCost, but is defined as a function of only R.)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Alert -Don't submit AI generated answer and i need unique response only if I see plagiarism then I'll reduce rating for sure.
4. An enclosure composed of a rectangular portion and a semicircular portion is to be
enclosed by a fence (solid line/curve). As described in more detail below, you will
write a program that determines the cost of fence for the enclosure. Note that the
cost per foot CostC for the curved portion of fence is greater than the cost Costs for
the straight portion.
a. Write a function FenceCost that will accept as input arguments values of the total
enclosure Area, the radius dimension R, and the costs per foot CostC and Costs for
the curves and straight fencing, respectively, and will return as output argument the
total cost of fence. (Hint: write an equation for Area and use it to determine a value for
L based on the inputs.) Test your function by verifying that it gives a result of $2181 for
the following input values: Area = 3000 ft2, R = 20 ft, CostC = $12 per foot,
CostS- = $9 per foot.
b. Write a script (program) that uses a nested for loop structure and fprintf to print a
table of fence costs for R values ranging from 10 to 40 ft in steps of 5, and Area values
ranging from 2500 to 3500 ft2 in steps of 100. (Use CostC = $12ft and CostS- = $9/ft
as before.) Call the function with scalar values of R and Area to calculate each fence
cost; do NOT use any arrays in this program.
c. Write a script that instead uses a "vectorized" approach, making use of the
meshgrid function, to calculate all of the same fence cost values above without using
any loops, but still using the FenceCost function to perform the calculation. In this
case, display the fence cost values in a properly-labelled 3D plot rather than in a table.
d. Write a script that prompts the user for the enclosure area, and then determines
and outputs the minimum total fence cost, along with the corresponding enclosure
dimensions R and L. Use the fencing costs per foot CostC and Costs from
part (a) above. Test your program for a user input of Area = 3000 ft2. (Hint: use
fminbnd on a function handle that uses FenceCost, but is defined as a function of only
R.)
Transcribed Image Text:4. An enclosure composed of a rectangular portion and a semicircular portion is to be enclosed by a fence (solid line/curve). As described in more detail below, you will write a program that determines the cost of fence for the enclosure. Note that the cost per foot CostC for the curved portion of fence is greater than the cost Costs for the straight portion. a. Write a function FenceCost that will accept as input arguments values of the total enclosure Area, the radius dimension R, and the costs per foot CostC and Costs for the curves and straight fencing, respectively, and will return as output argument the total cost of fence. (Hint: write an equation for Area and use it to determine a value for L based on the inputs.) Test your function by verifying that it gives a result of $2181 for the following input values: Area = 3000 ft2, R = 20 ft, CostC = $12 per foot, CostS- = $9 per foot. b. Write a script (program) that uses a nested for loop structure and fprintf to print a table of fence costs for R values ranging from 10 to 40 ft in steps of 5, and Area values ranging from 2500 to 3500 ft2 in steps of 100. (Use CostC = $12ft and CostS- = $9/ft as before.) Call the function with scalar values of R and Area to calculate each fence cost; do NOT use any arrays in this program. c. Write a script that instead uses a "vectorized" approach, making use of the meshgrid function, to calculate all of the same fence cost values above without using any loops, but still using the FenceCost function to perform the calculation. In this case, display the fence cost values in a properly-labelled 3D plot rather than in a table. d. Write a script that prompts the user for the enclosure area, and then determines and outputs the minimum total fence cost, along with the corresponding enclosure dimensions R and L. Use the fencing costs per foot CostC and Costs from part (a) above. Test your program for a user input of Area = 3000 ft2. (Hint: use fminbnd on a function handle that uses FenceCost, but is defined as a function of only R.)
Expert Solution
steps

Step by step

Solved in 6 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education