Question

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1
function areaCircum(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 pi*r^2
    and the circumference is 2*pi*r. The function is called areaCircum.
    Example: areaCircum(input value)
    %}

    % areaCircum(10)

    fprintf("Area of circle with radius %f is %f\n", radius, pi*radius^2)
    fprintf("Perimeter of circle with radius %f is %f\n", radius, 2*pi*radius)
end

below is the testing code.. İgnore if not needed

areaCircum(10)

Add a comment
Know the answer?
Add Answer to:
MatLab question, please answer in matlab. %{ Write a function that prints the area and circumference...
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
  • 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.

  • 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.

  • Please upload screenshots of the code. Thank you! P1 - Circle Area and Circumference functions.cpp, functions.h,...

    Please upload screenshots of the code. Thank you! P1 - Circle Area and Circumference functions.cpp, functions.h, P1.cpp The user enters 3 floating-pointer numbers which correspond to 3 radi. Store these numbers in an array. Then, define and prototype a function void area and cireffloat* area, float circumference, float array) which takes as input the array of circumferences of circles with the input radii. Think about why we need to pass pointers for both the area and the circumference variables. radii...

  • 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...

  • modify sample code from example two to calculate the surface area and volume of a sphere...

    modify sample code from example two to calculate the surface area and volume of a sphere givin the radius int main() Example 2 Introduction to structures and passing the structure variables as arguments into functions. 1. A structure is created with circle related variables. 2. Two functions are created related to circle calculations. 3. This example passes structure variables from the main function to the message Circle function 4. The message Circle function converts the structure variables into regular double...

  • 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...

  • 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...

  • Write a C program named assignment04.cpp that will ask for and read in a float for...

    Write a C program named assignment04.cpp that will ask for and read in a float for a radius ask for and read in a float for the height each of the following functions will calculate some property of a shape (area, volume, circumference, etc) The functions will accept one or two parameters (radius and/or height) and return the proper calculation. There is no input/output (cin or cout) in the function – just the calculation write the following functions float areaCircle(float...

  • 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 java class definition for a circle object. The object should be capable of setting...

    Write a java class definition for a circle object. The object should be capable of setting radius, and computing its area and circumference. Use this to create two Circle objects with radius 10 and 40.5, respectively. Print their areas and circumference. Here is the Java class file (Circle.java). Compile it. public class Circle{ //Instance Variables private double PI = 3.1459; private double radius; //Methods public Circle ( ) { }    //get method (Accessor Methods ) public double getRadius (...

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