The syntax is very simple,
if (P1>=P1min) && (P1<=P1max)
fprintf 'Machine 1 is in limits'
elseif (P2>=P2min) && (P2<=P2max)
fprintf 'Machine 2 is in limits'
else
P1=P1max
P2=pd-(P1max+P3min)
P3=P3min
end
you only need one 'end'.
