Question

4.4 Advanced Functions Modify ellipsoidinfo.m, so that the function returns some information about an ellipsoid (or sphere) d× π × radius 3 Surface Area of a Sphere 4 × π × radius Volume of an Ellipsoid (Approximate) Surface Area of an Ellipsoid for

(MATLAB QUESTION) How to modify this function?

function [ varargout ] = ellipsoidInfo( varargin )
% enter code/comments here
end

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

Program:

ellipsoidinfo.m 1 function varargout ]-ellipsoidinfo( varargin ) 2 3 4 5 6 if nargin- 1 r-vararginflj v= (4/3) * pi * (r^3);

Code:

function [ varargout ] = ellipsoidinfo( varargin )
if nargin == 1
    r = varargin{1};
    v = (4/3) * pi * (r^3);
    varargout{1} = v;
    if nargout == 2
      s = 4 * pi * (r^2);
      varargout{2} = s;
    end
elseif nargin == 3
    a = varargin{1};
    b = varargin{2};
    c = varargin{3};
    p = 1.6075;
    v = ( 4/3 ) * pi * a * b * c;
    varargout{1} = v;
    if nargout == 2
      s = 4 * pi * ( ( ( (a^p)*(b^p) + (a^p)*(c^p) + (b^p)*(c^p) ) / 3 ) ^ (1/p) );
      varargout{2} = s;
    end
else
    error('give correct number of arguments!')
end

Execution and Output:

ellipsoidinfo(1) v= 4.1888 [v s] = ellipsoidinfo(1) >> s= 12.566 ellipsoidinfo(1, 2, 3) v-25.133 >> [v s] = ellipsoidinfo ( 1

Add a comment
Know the answer?
Add Answer to:
(MATLAB QUESTION) How to modify this function? function [ varargout ] = ellipsoidInfo( varargin ) %...
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 QUESTION) function [ volume , area ] = cylinderInfo( height , radius ) %...

       (MATLAB QUESTION) function [ volume , area ] = cylinderInfo( height , radius ) % % end function [ volume ] = calcVolume( height , radius ) % % function [ area ] = calcSurfArea( height , radius ) % % end 4.3 Subfunctions D Modify cylinderInfo.m, so that the function returns the volume and area of a cylinder, given the height and radius of the base. Volume x radius2 x height Surface Area 2 x radius2 +height x...

  • Nay programming languge is fine (MatLab, Octave, etc.) This is the whole document this last picture...

    Nay programming languge is fine (MatLab, Octave, etc.) This is the whole document this last picture i sent is the first page 5. Write and save a function Sphere Area that accepts Radius as input argument, and returns SurfaceArea (4 tt r) as output argument. Paste the function code below. Paste code here 6. Validate your Sphere Area function from the command line, checking the results against hand calculations. Paste the command line code and results below. 7. Design an...

  • Write a user-defined MATLAB function that will calculate the area/volume of a shape whose dimensions are...

    Write a user-defined MATLAB function that will calculate the area/volume of a shape whose dimensions are given by the user. This function will be able to calculate the area for 2D objects like a triangle or a rectangle and 3D objects such as a box. The name of the function will be findArea and it will have four input arguments. The first input argument will be the length. The second input argument will be the width. The third input argument...

  • can anyone help me with the matlab? U Ulube canvas C by Physics for Sci. US...

    can anyone help me with the matlab? U Ulube canvas C by Physics for Sci. US ABC Radio Mall-dantul @ Science News, Art Courses LMS Integration Documentation 202010 EGR 1302.3 > HW05 - MATLAB Functions > Sphere O solutions submitted (max: 3) Write a function named sphereVSA to compute the volume and surface area of a sphere given the radius. The input to your function is a single number thera should output two numbers, first volume, then surface area. These...

  • read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates th...

    read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates the BMI using the equation below, displays the BMI category, and outputs the BMI value tothe user's program W (kg) h2 (m2) BMI Display Normal if 18.5 s BMI 25 Display Overweight if 25 s BMI <30 Display Obese if BMI 2 30 Else display underweight So you will create two...

  • Please help! CS Problem Set 5 #Write a function called sphere_data. volume_and_area will #take in a...

    Please help! CS Problem Set 5 #Write a function called sphere_data. volume_and_area will #take in a dictionary. This dictionary is guaranteed to #have exactly one key: "radius", whose value is an integer #representing the radius of a sphere. # #Modify this dictionary to add two keys: "volume" and "area". #The values associated with these keys should be the volume #and surface area of the sphere. # #The formula for volume is: # (4/3) * pi * radius ^ 3 #...

  • Can someone help me with this coding question. I cannot get this to run properly. Write...

    Can someone help me with this coding question. I cannot get this to run properly. Write a program that defines the named constant PI, const double PI = 3.14159;, which stores the value of π. The program should use PI and the functions listed in Table 6-1 to accomplish the following: Output the value of √π . Prompt the user to input the value of a double variable r, which stores the radius of a sphere. The program then outputs...

  • iIn python please AutoSave H L04-3b Testing Lab - Protected View - Saved to this PC-...

    iIn python please AutoSave H L04-3b Testing Lab - Protected View - Saved to this PC- Search A [email protected] J 7 File Home Insert Draw Design Layout Share Comments References Mailings Review View Help Areas and Volumes We'll write a program that prompts the user for a radius and then prints: a) The area and circumference of a circle with that radius b) The volume and surface area of a sphere with that radius 1. To get started, what is...

  • matlab 1. Write a MATLAB user-defined function that finds the largest element(s) of a matrix. Name...

    matlab 1. Write a MATLAB user-defined function that finds the largest element(s) of a matrix. Name the function [max_value, max_index] - LASTNAMES matrix max (x), where input argument x is a vector or matrix (not a scalar), and the outputs are the maximum value(s) and indexes of the maximum value(s) of the mput x. Do not use MATLAB functions max() or find(). Use loops and if branches to determine the maximum elements of matrix. Check for correct number and valid...

  • Matlab A forus is shaped like a doughnut. If its inner radius isa and its outer...

    Matlab A forus is shaped like a doughnut. If its inner radius isa and its outer radius is b, its volume and surface area are given by V '(a + b(b - a)? A = (b2 - ) a. Create a user-defined function that computes V and A from the arguments a and b. LastName_FirstName_P4_fn_calc. b. Test for values where acb, ab and aub. Use values between 1 and 10 for a and b. Your output should show a, b,...

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