Finding volume using quad function

조회 수: 7 (최근 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