I want to write a Matlab function with 'h' and 'V' as vectors to determine the fluid volume of a tank, but I have a problem with the function. The error is in the body of the question. Can someone help me?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
function V = hstank2(h,r,hcl) r=0.40; hcl=1.2; Nh = 41; h=linspace(0,(2*r+hcl),Nh); V = zeros(size(h)); i= (h>=0)&&(h<=r); V(i)=(pi/3).*(r.^2*(3.*h(i)-r)-(h(i)-r).^3); i= (h>=r)&&(h<=r+hcl); V(i)=((2/3)*pi*r.^3)+(pi*r.^2.*(h(i)-r)); i= (h>=r+hcl)&&(h<=2*r+hcl); V(i)=((2/3)*pi*r.^3)+(pi*r.^2*hcl)+((pi/3)*... (3*r.^2.*(h(i)-r-hcl)-(h(i)-r-hcl).^3)); end
OUTPUT: Operands to the and && operators must be convertible to logical scalar values.
Error in hstank2 (line 5) i= (h>=0)&&(h<=r); V(i)=(pi/3).*(r.^2*(3.*h(i)-r)-(h(i)-r).^3);
0 comentarios
Respuestas (1)
Ver también
Categorías
Más información sobre Fluid Dynamics en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!