I have a problem statement where i have to change the elements of a vector depending on some condition
the vector comprises of random number between 4 to 12 i.e. 4,5,6,7,8,9,10,11,12
for eg. the given vector is A = [ 5,6,8,9,7,5,4,12,11,9,10]
now i have to add a scalar to the given vector , which can be either a -ive number or a +ive number
and any element of the resultant vector greater than 12 should be wrap around and any if the element is smaller than 4 then also it should be wrapped around.
for eg. if my input scalar is 3 , then the element 11 in input vector after addition operation will become 15 which is greater than 12
and should be wrapped around and changed to 5 , like shift in a circular manner.
in second case taking the input scalar as -4 to be added to the vector A , the element 6 will become 2 and should be wrapped around and changed to 11
I can solve this using for loop and if else statement , but i am interested in solving this via logical indexing.
any help on that will be greately appreciated.