Borrar filtros
Borrar filtros

stuck in a while loop

2 visualizaciones (últimos 30 días)
Jonathan Ish-Shalom
Jonathan Ish-Shalom el 8 de Mayo de 2020
Comentada: Jonathan Ish-Shalom el 8 de Mayo de 2020
My code is stuck in the determine_dh section when I try to run it and I can't figure out why. If you look in my code it seems that keeps looping through the "while" function. If you could help me debug this that would be great.
function [dhn] = determine_dh(acc,doverhstart,Ka1Kp1,ah,l1h,P1)
dho=doverhstart;
dhn=1000;
while abs(dhn-dho)>acc
dho=dhn;
bh = 1+dho-l1h;
dhn=find_dh(Ka1Kp1,dho,ah,bh,P1);
end
end
For refrence here is find_dh
function [dhout] = find_dh(Ka1Kp1,dh,ah,bh,P1)
numerator1=2/3*(1+dh)^2*Ka1Kp1*(dh+1-3/2*ah);
numerator2=P1*bh^2*((1/3)*bh-1-dh+ah);
denominator=2/3*dh+1-ah;
dhoutsq=(numerator1-numerator2)/denominator;
dhout=sqrt(dhoutsq);
end
  2 comentarios
Akihumi
Akihumi el 8 de Mayo de 2020
Could you please provide some sample input? Or you can try setting a breakpoint before the while loop and run line by line to check the changes of dhn, dho, and other variables.
You can also set a breakpoint in find_dh or press F11 or 'Step In' to enter find_dh to check the changing variables inside find_dh.
Jonathan Ish-Shalom
Jonathan Ish-Shalom el 8 de Mayo de 2020
putting a break point helped! thanks

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by