Too many input arguments?

Hello. I'm trying to create a MATLAB function file which will determine the surface area and volume of partial sphere. The user will enter the sphere diameter and the angular portion of the sphere in degrees.
Here is my function so far.
function [Volume,SurfaceArea] = ObamaBarackSphereF(Diameter,Angle)
% This is a function that will determine the surface area and volume of a
% partial sphere. The input arguments are the sphere's diameter and the
% angular portion of the sphere in degress.
Radius = Diameter/2;
Proportion = Angle/360;
if Diameter > 0;
if Angle == 360;
Volume = (4/3)*pi*(Radius)^3;
SurfaceArea = 4*pi*Radius^2;
elseif Angle > 0 && Angle < 360;
Volume = Proportion*(4/3)*pi*Radius^3;
SurfaceArea = (Proportion*4*pi*Radius^2)+(pi*Radius^2);
end
end
end
However, when I try to run it, the command window says:
Error using ObamaBarackSphereF (line 6) Not enough input arguments.
Line 6 refers to the line that says "Radius = Diameter/2;"
What am I doing wrong here?

1 件のコメント

Carlos
Carlos 2013 年 3 月 25 日
I have called the function in this way
>> ObamaBarackSphereF(2,20)
Giving this result
ans =
0.2327

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2013 年 3 月 25 日
編集済み: Image Analyst 2013 年 3 月 25 日

0 投票

It runs just fine for me, I mean other than the formula being totally wrong. It doesn't say anything about not enough inputs. You do know that using angles between 0 and 360 for a sphere doesn't make sense don't you? I guess apparently not. You need to pass in "Solid angle" which goes from 0 to 4*pi steradians.
Proportion = SolidAngle/(4*pi);
Also I don't see any involvement of Barack Obama in your program so you might pick a more descriptive name for your function.

5 件のコメント

David
David 2013 年 3 月 25 日
I do not know much about using steradians for a sphere but my professor explicitly said to use degrees for the angular portion of the sphere.
Also, how did the function work for you? I just tried to run it and the same error message came up.
Carlos
Carlos 2013 年 3 月 25 日
Typing this,
ObamaBarackSphereF(2,20)
the function runs perfectly well for me
David
David 2013 年 3 月 25 日
Why did you input those specific values?
Image Analyst
Image Analyst 2013 年 3 月 25 日
Ask your professor what a steradian is and see if he knows. Ask him why he is not using steradians, and what degrees means in a 3D situation. If he means the angle of the solid cone, like theta in this page http://en.wikipedia.org/wiki/Steradians then you'll need to convert that cone angle into steradians.
Jan
Jan 2013 年 3 月 25 日
編集済み: Image Analyst 2013 年 3 月 25 日
Why not use those values?

サインインしてコメントする。

カテゴリ

質問済み:

2013 年 3 月 25 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by