Can someone show me where my matlab code is wrong. my kvaluse never change either, and baseball is a constant you can see how it is dervived in the code.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
1 comentario
Respuestas (1)
Milan Padhiyar
el 30 de Oct. de 2020
Hello,
I can see that the function F is of variables x and y, but your function handle definition does not include the variable x and y in the expression. So, it looks likes that your function appears to be is constant.
Please make the following changes in your function if you want to use baseball and v as a variable for the function handle.
F =@(baseball,v) (baseball * sqrt(v));
Now you will be able to see that values of k1 to k4 are changing.
I hope this helps you to resolve your query.
Thanks
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!