Greetings all
logic for adjusting max number in array to min number in second array
I have an array "A"
A=[0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1 .9 .8 .7 .6 .5 .4 .3 .2 .1 0 -.1 -.2 -.3 -.4 -.5 -.6 -.7 -.8 -.9 -1 -.9 -.8 -.7 -.6 -.5 -.4 -.3 -.2 -.1]
And I want the second array to be going in the "opposite" direction so when the numbers are going high in array "A" the numbers in array "B" should be going low
example of what array "B" should look like
B=[1 .9 .8 .7 .6 .5 .4 .3 .2 .1 0 -.1 -.2 -.3 -.4 -.5 -.6 -.7 -.8 -.9 -1 -.9 -.8 -.7 -.6 -.5 -.4 -.3 -.2 -.1 0 .1 .2 .3 .4 .5 .6 .7 .8 .9]
I tried using this logic but it makes everything positive of course
arrayB=-abs(arrayA).+abs(max(arrayA));
but that didn't work I'm using matlab but if someone knows the correct logic I can convert it over the matlab syntax
The numbers represent different amplitudes of a signal so when the amplitude of one signal arrayA is going up the other signal arrayB should be going down. There is "overlap"
tia
To answer this here are some ways to do this
1st) way
2nd) way
3rd) way Another solution in this case is simply to create a circular shift of A using array indexing. For example, shifting the array A such that its maximum value is at the beginning of the array will give you the desired array B:
thanks goes to gnovice for his/his help