Not getting proper output for if logic

2 visualizaciones (últimos 30 días)
Jeevan Patil
Jeevan Patil el 3 de En. de 2012
if (Proportional_valve == 2);
Prr_1UL = min(Mod_P_cutoff,Pr);
Prr_1L(i) = min(Mod_P_cutoff,Pr);
elseif (Proportional_valve == 1)
if Pr > Kppo;
Prr_1UL = Kppo + ((PLCRV_UL-Kppo)*Pr/(PLCRV_max-Kppi));
Prr_1L = Kppo + ((PLCRV_L-Kppo)*Pr/(PLCRV_max-Kppi));
else
Prr_1UL = min(Mod_P_cutoff,Pr);
Prr_1L = min(Mod_P_cutoff,Pr);
end
end
in above loop if Proportional_valve == 1 and if Pr>Kppo then program is not using the formula mention in the program if statement is true
Prr_1UL = Kppo + ((PLCRV_UL-Kppo)*Pr/(PLCRV_max-Kppi));
Prr_1L = Kppo + ((PLCRV_L-Kppo)*Pr/(PLCRV_max-Kppi));
it is always clculating the pressure by using
Prr_1UL = min(Mod_P_cutoff,Pr);
Prr_1L = min(Mod_P_cutoff,Pr);
I am giving Pr as a input array. Rest of the parameter are constant
Can anybody help me why this logic is not working..
Regards
Jeevan Patil

Respuesta aceptada

TAB
TAB el 3 de En. de 2012
What is constant Kppo, array or scalar?
If you are passing Pr as array (not scalar), then comparison of all element must be true to make condition true.

Más respuestas (2)

Andrew Newell
Andrew Newell el 3 de En. de 2012
You mention that Pr is an array. If you use
if Pr > Kppo
then all the elements of Pr must be greater than Kppo for the statement to be true. You need
if Pr(i) > Kppo

Jeevan Patil
Jeevan Patil el 19 de En. de 2012
Thanks Tabrez, Andrew Newell, it is working fine now

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by