Question

MATLAB- Write a function that prints the area Write a function that prints the area and...

MATLAB- Write a function that prints the area Write a function that prints the area and circumference of a circle for a given radius. Only the radius is passed to the function. The function does not return any values. The area is given by π r2 and the circumference is 2 π r.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The following code gives you the required functionality

function circle(rad)
ar = pi * rad * rad;
cf = 2* pi * rad;
fprintf("The area and circumference of circle with radius %0.2f are %0.2f and %0.2f",rad, ar, cf)
end
circle (7)

Snapshot of code:

function circle (rad) ar- pi rad rad; cf 2* pi rad; fprintf(The area and circumference of circle with radius %0.2f are %0.2fOutput of the code:

Warning: Tunctioh ./delmo.m Shadows a core (1brary Tunct1on The area and circumference of circle with radius 7.00 are 153.94

Add a comment
Know the answer?
Add Answer to:
MATLAB- Write a function that prints the area Write a function that prints the area and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a function that prints the area and circumference of a circle for a given radius....

    Write a function that prints the area and circumference of a circle for a given radius. Only the radius is passed to the function. The function does not return any values. The area is given by π r2 and the circumference is 2 π r.

  • MatLab question, please answer in matlab. %{ Write a function that prints the area and circumference...

    MatLab question, please answer in matlab. %{ Write a function that prints the area and circumference of a circle for a given radius. Only the radius is passed to the function. The function does not return any values. The area is given by pi*r^2 and the circumference is 2*pi*r. The function is called areaCircum. Example: areaCircum(input value) %} % Place your function call here

  • Write a program that calculates the area and circumference of a circle. It should ask the...

    Write a program that calculates the area and circumference of a circle. It should ask the user first to enter the number of circles n, then reads the radius of each circle and stores it in an array. The program then finds the area and the circumference, as in the following equations, and prints them in a tabular format as shown in the sample output. Area = πr2 , Circumference = 2πr, π = 3.14159 Sample Output: Enter the number...

  • matlab The Homework should be submitted as a script (.m) file Write a script areaMenu that...

    matlab The Homework should be submitted as a script (.m) file Write a script areaMenu that will print a menu consisting of "Cylinder," "Circle," and "Rectangle." It waits for the user to choose from the menu then call the corresponding function of each choice as follows: 1- Cylinder will call the function (cyl) which prompts the user for the radius and height of the cylinder, then calculates and prints area of the cylinder. 2- Circle will call the function (cir)...

  • Write a matlab script(using only matlab) for this. Write a script to solve the following problem:...

    Write a matlab script(using only matlab) for this. Write a script to solve the following problem: Ask the user for the length and the width of a rectangle. These need to be passed to a function. The function is to calculate and return the area and the perimeter of the rectangle. The area is the length times the width and the perimeter is 2 times the length and 2 times the width. Make sure to suppress all output from the...

  • Please use matlab cars. Answer: Function file; Command Window: 5.4 Write a user-defined function that plots...

    Please use matlab cars. Answer: Function file; Command Window: 5.4 Write a user-defined function that plots a circle given the coordinates of the center and the radius. For the function name and arguments use circleplot(x,y,R). The input arguments are the and y coordinates of the center and the radius. Use linspace to generte the angle from 0 to π with 100 points. (Hint: the circle equation: x+Rcos and yy-yRsin 0.) This function has no output arguments. Plot the circle using...

  • Write the code in LISP that define a function(named area-circle) that would calculate (return) the area...

    Write the code in LISP that define a function(named area-circle) that would calculate (return) the area of a circle when the radius of the circle is given as an argument. The function should be able to be called as follows (area-circle 10)

  • A) One of the problems that have been discussed in the class is to write a simple C++ program to ...

    C++ programming question will upvote A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...

  • The circumference of a circle is found by multiplying twice the radius by π. If you...

    The circumference of a circle is found by multiplying twice the radius by π. If you let π = 3.14 then: (a) Using function notation, write the circumference of a circle as a function of the radius, r (b)  using the function from part (a), evaluate the function to find the circumference of a circle with radius 7 inches. Show how you get your answer.

  • A) One of the problems that have been discussed in the class is to write a...

    A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following: int main() { double radius; double area; double circumference; //the radius...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT