From: Michael on
hi,

i have 2 vectors input as follow:

a = [0;1;1;0;1;0;0;0;0;1]
b = [0;0;0;0;0;0;0;-1;0;0]

and the output i am trying to generate is
c = [0;1;1;1;1;1;1;0;0;1]

whereby the logic is as follow:
1. if a is '1', c='1'. ('ON' mode)
2. if a is in 'ON' mode, c will always be '1'.
3. if b is '-1', c='0'. ('OFF' mode)
4. if b is in 'OFF' mode, c will always be '0'.

may i ask if there is any matlab function that does this logic?
or is there any efficient ways of getting the output instead of using for-loop?

thanks in advance for sharing!

cheers!
Michael