-1

I'm taking a course in matlab and was given the assignment attached.

below are my codes for my function. But when I enter 3 as the input value for the radius I get the output of 810.4933 which I'm pretty sure is not right.

function arad=funcup(r)

v=10;

arad=pirsqrt((r^2)+((3*v/pi*r^2)^2));

end

I didn't place any sets of codes because I don't know where to start. He also mentioned that for (b.) instead of using a global variable we could use a constant since he hasn't taught global variables.

Any help will be greatly appreciated.

Jessie
  • 3
  • 3

1 Answers1

-1

Area in terms of radius and height is as follows:

enter image description here

function for computing area as specified in the assignment:

%%cone_area
%Computes the area of a cone.
%Depends on a globally defined volume V
function area = cone_area(r)
    global V;
    area = sqrt(pi^2 * r^6 + 9 * V^2) / r;
end

In the command window, you should declare V as a global variable like so

>>> global V;

This way cone_area has access to V.

To compute the value of r which minimises the Area, a reasonable upper bound is the given volume. Using fminbnd:

min_r = fminbnd(@cone_area, 0, V)

Feel free to adjust the upper bound as needed. This should get you on the right track.

You can find details on fminbnd from Matlab's site. Details of global variables and their usage can also be found here

Xero Smith
  • 1,968
  • 1
  • 14
  • 19
  • I tried plotting the function as asked in the section C for the assignment but I'm getting straight line. I may be doing something wrong due to not knowing how to plot after using the fminbnd function. This is what i used to plot fplot(min_r,[0 10]) – Jessie Oct 22 '17 at 10:34