trying to converge a variable/value used in a equation

i am fairly new to matlab and i have been trying to get a variable/value to converge but it looks like i am getting an infinite loop. can someone help me speed it up, tell me what is wrong or suggest a different approach. the following code is in a loop and thetadot is the value im trying to find at that point in time
b = 10;
torque_interation = zeros(1,(size(hx,2)-1));
deltaKE = 100;
thetadot(1,1) = RPS*2*pi();
while abs(deltaKE) > 0.1
q = thetadot(1,1);
torque_interation(1,i) = (work_increment(1,i)*RPS)/q;
% work in - work out = deltaKE
deltaKE = work_increment(1,i) - torque_interation(1,i)*q;
if deltaKE > 0
q = q + b;
elseif deltaKE < 0
b = b/2;
q = q - b;
end
end
thetadot(1,i) = q;

3 comentarios

Post all the relevant details, for example what's RPS.
shaun
shaun el 30 de Mayo de 2011
RPS = reverlations per second (500/60)
work_increment = work done by steam, it is different at every degree of rotation
hx is the distance piston has moved.
shaun
shaun el 30 de Mayo de 2011
torque_interation (spelling error) is the torque at that point in time

Iniciar sesión para comentar.

 Respuesta aceptada

If you combine these two lines
torque_interation(1,i) = (work_increment(1,i)*RPS)/q;
deltaKE = work_increment(1,i) - torque_interation(1,i)*q;
you get
deltaKE = work_increment(1,i)*(1-RPS);
so values of q and b don't have any effect.

Más respuestas (0)

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 30 de Mayo de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by