I'm basically trying to get the value of "F" be within 10% of the "W" value. When I run this code and watch the output, I can see the "forceErr" values drop below 10% but my while loop won't terminate for some reason. Can anyone figure out why?
format longr = 0.1;h = 0.5;m = 6;g = 9.81;W = m*g;rhoFluid = 1000;forceErr = 1;while forceErr > 0.1 for z = 0:0.01:0.5 pressure = rhoFluid*g*z; for theta = 0:pi/50:2*pi A = 1/2*r^2*theta; F = A*pressure; forceErr = abs((F - W)/W) end endend
Best Answer