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