Finding volume using quad function

8 次查看(过去 30 天)
Amanda
Amanda 2011-4-7
This is the problem I have to solve. I keep getting an error message though and can't figure out what's wrong with it.
Find the volume of revolving the area of the circle(x-6)^2 +(y-7)^2 =5 about the x-axis.
R= 7+sqrt(5-(x-6)^2)
r= 7-sqrt(5-(x-6)^2)
Volume= quad('circle',(6-sqrt(5)),(6+sqrt(5)))
function [ z ] = circle( R, r )
z= pi(R.)^2 -pi(r.)^2
end
Any help would be great! Thanks
  2 个评论
Andrew Newell
Andrew Newell 2011-4-7
There are lots of errors. Are you using the MATLAB editor? Put your mouse over any red line and you'll see some specific problems.
Amanda
Amanda 2011-4-7
Yes, I am. It doesn't say that there are errors until I run it.

请先登录,再进行评论。

回答(2 个)

John D'Errico
John D'Errico 2011-4-7
You define a function called circle.
function [ z ] = circle( R, r )
R= 7+sqrt(5-(x-6)2)
r= 7-sqrt(5-(x-6)2)
z= pi(R.)2 -pi(r.)2
It has input arguments R and r. Then you try to define the variables R, r, both of which are functions of something called x. Where did x come from? Did you provide it as an input to circle? (No.) In fact, there is no need to pass in R and r into the function circle if you compute them inside the function!
Next, you don't seem to know matlab syntax. What does this mean:
(x-6)2
????? I think you wanted to square (x-6) ? If so, there IS an operator to raise a number to a power. Learn it. Use it.
At the end of circle, you try to define the output z.
z= pi(R.)2 -pi(r.)2
Again, I think you need to read the beginning matlab tutorials about basic syntax. This line has too many syntax errors in it to list.
  3 个评论
Amanda
Amanda 2011-4-7
What value would I make x based off of how I'm revolving the equation of a circle around the x axis which makes a doughnut like shape?
Amanda
Amanda 2011-4-7
What value would I make x based off of how I'm revolving the equation of a circle around the x axis which makes a doughnut like shape?

请先登录,再进行评论。


Andrew Newell
Andrew Newell 2011-4-7

To follow up on a comment - if you are using a MATLAB editor, you should see something like this:

You will certainly have a red button on the right margin indicating errors. Mouse over the red lines and you will see details.

Also, most of John's comments still apply even after your changes - especially the one about reading some MATLAB tutorials.

  2 个评论
Amanda
Amanda 2011-4-7
I know what the lines mean. The only thing it says is.. Terminate statement with semicolon to suppress output.
Amanda
Amanda 2011-4-7
What value would I make x based off of how I'm revolving the equation of a circle around the x axis which makes a doughnut like shape?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by