I have a Matlab array of variable size of zeros and a list of characters in a cell array.
cell array:
{'0000'}
{'0011'}
I want to place -1 in the array for each 0 bit and place 1 for 1 bit.
example:
-1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 -1 -1 -1 -1 0 0 0 0 0 0 0 0
....
0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 -1
-1 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
...
0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 1 1
As you can see based on the cell array bits {0000}
first four output rows completely place these 4 translated bits in all output rows. Same for the second character {0011}
. Array size for this case is (8 by 16). The number of times -1 -1 -1 -1
in the array propagates from left to right is also variable -- for this case, it is up to 4 columns of 4 bits.
In the same way, if there were 5 bits for example:
cell array:
{'00000'}
{'00111'}
This would be the array:
-1 -1 -1 -1 -1 0 0 0 0 0
0 0 0 0 0 -1 -1 -1 -1 -1
-1 -1 1 1 1 0 0 0 0 0
0 0 0 0 0 -1 -1 1 1 1
In this case, the array size is (4 by 10) as the number of times -1 -1 -1 -1 -1
in the array propagates from left to right is up to 2 columns of 5 bits.
The first example gets 4 propagation and the second example has only 2 because the available column number is also a variable. This is a separate parameter.
Here is my code that is not working:
counterop=0
counter=1
for i=1: numel(listofss) % list of ss is the list of charecters (my examples has 3)
for c = 1:1:(ss) % row
for e = counter:counter+(n-1) % column
A_ss(c ,e)= -1 %A_ss is the predefined matrix (in my example a 12 by 64 matrix )
end
counter=counter + n
counterop=counterop+1
end
end
if counterop > n-1
counter = 1
counterop=1
end
A working code with for loop preferably would be appreciated.