Not getting proper output for if logic

1 view (last 30 days)
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

Accepted Answer

TAB
TAB on 3 Jan 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.

More Answers (2)

Andrew Newell
Andrew Newell on 3 Jan 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 on 19 Jan 2012
Thanks Tabrez, Andrew Newell, it is working fine now

Tags

Products

Community Treasure Hunt

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

Start Hunting!