Replace
c = (x ? a : b)
by
c = subsref({b; a}, substruct('{}', {x + 1}))
x should be a boolean value or 1 or 0.
true or 1 will select a
false or 0 will select b
This should work with all what cells can contain and can also be used in an intricate formular!