MATLAB: Not getting proper output for if logic

loopMATLABoutput

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

Best Answer

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.
Related Question