can someone show me where my matlab code is wrong. my k values never change either

1 次查看(过去 30 天)
can someone show me where my matlab code is wrong. my k values never change either

回答(1 个)

Mitchell McKinney
Mitchell McKinney 2020-10-27
clear;
h=60 %stepsize
hof=240 %inches in water
dtank=120 %diameter of tank in inches
dnozzle=1.049 %diameter of nozzle in inches
areanozzle=((dnozzle^2)*pi)/4 %area of nozzle
areaoftank=((dtank^2)*pi)/4 %area of tank
v=areaoftank*hof %initial volume of water in tank
c=.6 %tank discharge coefficiant
g=386.088 %force of gravity
b=dnozzle/dtank %beta
baseball=-areanozzle*c*(sqrt((2*g)/((1-b^4)*(areaoftank))))
F =@(x,y) (baseball * sqrt(v)); %function
i=0
while v>0
i=i+1;
k1=F(baseball,v)
k2=F(baseball + .5*h,v + .5*h*k1)
k3=F(baseball + .5*h,v + .5*h*k2)
k4=F(baseball + .5*h,v + h*k3)
v=v+ (1/6) *(k1 + 2*k2 + 2*k3 + k4)*h
end
v
seconds=i*h/60
height=v/areaoftank

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by