From: Michelle on 18 Jan 2010 17:11 Hi, I'm trying to create a function m-file that will compute the work required to pump all the water out and up to a point which is distance a above the top of a point-down conical tank with radius r and height h. The function takes r, h, and a as it's three arguments. I'm using quad for the integral. I need to use the m-file to evaluate a tank with r=7, h=2, and an unknown a, but matlab just keeps telling me that a is undefined. I know that the if I integrate with respect to the right variable the integral should be able to handle 'a' being an uknown constant, but I can't figure out how to do that. Here's the m-file I have right now: function t=fuckmylife15(r,h,a) syms x; t=62.5 * quad(@(x) pi .* r .^2 .* ((h+a)-x), 0, h+a) Any help would be greatly appreciated. Thanks.
From: Michelle on 18 Jan 2010 17:19 Whooooops, probably should have changed that function name before posting it here. Sorry.
From: Michelle on 18 Jan 2010 18:06 And I fixed my integral: 62.5 * quad(@(x) pi .* ((r./h).* x) .^2 .* ((h+a)-x), 0, h+a)
From: John D'Errico on 18 Jan 2010 18:10 "Michelle " <captainofthestarshipenterprise(a)hotmail.com> wrote in message <hj2m9o$lsl$1(a)fred.mathworks.com>... > Hi, > > I'm trying to create a function m-file that will compute the work required to pump all the water out and up to a point which is distance a above the top of a point-down conical tank with radius r and height h. The function takes r, h, and a as it's three arguments. I'm using quad for the integral. > I need to use the m-file to evaluate a tank with r=7, h=2, and an unknown a, but matlab just keeps telling me that a is undefined. I know that the if I integrate with respect to the right variable the integral should be able to handle 'a' being an uknown constant, but I can't figure out how to do that. > Here's the m-file I have right now: > > function t=integrate_this(r,h,a) > syms x; > t=62.5 * quad(@(x) pi .* r .^2 .* ((h+a)-x), 0, h+a) > > Any help would be greatly appreciated. Thanks. You apparently wish to integrate this as a function of a, where a is left symbolic. The flaw in your plan is that quad is a NUMERICAL integration tool. It cannot integrate a symbolic integrand. For that, you need to use the integration facility of the symbolic toolbox. John
|
Pages: 1 Prev: a simple pde question, please don't ignore Next: jcombobox is called twice instead of once! |