hello,
i am having a bit string (say 'a') of size 756*1...and another bit string (say b) of size 576*1...now, i want many to one mapping to be performed on this bit string..
for example: the operation to be performed is shown below
b(k)= a(j) j=1....756, k= j mod 576...

1 Kommentar

Guillaume
Guillaume am 20 Mär. 2017
k cannot be j mod 576 as this would produce zero indices. k could be ((j-1) mod 576)+1

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 20 Mär. 2017

0 Stimmen

Afterwards, should b(1) be assigned the value of a(1), or should it be assigned the value of a(577) ?

17 Kommentare

Jyothi Alugolu
Jyothi Alugolu am 20 Mär. 2017
it's many to one mapping,means same index will be mapped to more than one element..i.e a(1) and a(577) both must be mapped to b(1)...
Walter Roberson
Walter Roberson am 20 Mär. 2017
Is it correct that b(1) would somehow have to store both a(1) and a(577) distinctly? In any particular order? How would the user indicate which of the "many" to access?
Are you trying to create a hash table? If you are then what is your collision strategy?
Jyothi Alugolu
Jyothi Alugolu am 20 Mär. 2017
Bearbeitet: Walter Roberson am 20 Mär. 2017
A binary string {b(j)} j=1..756.. To achieve many-to-one mapping, we now need to apply the modulo operation to the index j of the binary string {b(j)}, i.e., j mod 576... We then map the elements of {b(j)} to a new (shortened) binary string {b(k)} as follows:
b(k) =b(j), k = j mod 576, j = 1, · · · , 756 , k=1...576...
Walter Roberson
Walter Roberson am 20 Mär. 2017
Bearbeitet: Walter Roberson am 20 Mär. 2017
No, that definition does not work. That requires that the original b(1) and the original b(577) are both at b(1) in some undefined way.
Jyothi Alugolu
Jyothi Alugolu am 20 Mär. 2017
for example: if j=1..10 and s=5,then k=j mod s..which means a(1) and a(6) which has same mod values must store in b(k)...
Yes, but which one? If you start with (say)
b = [1 1 1 1 1 0 0 0 0 0]
and s = 5, then after the mapping, b(1) would have to be both 0 and 1, but which one?
Jyothi Alugolu
Jyothi Alugolu am 20 Mär. 2017
both 0 and 1...if,suppose a(1) has bit value 0 and a(6) has bit value 1,then b(1) must have both 0 and 1
Jyothi Alugolu
Jyothi Alugolu am 21 Mär. 2017
a(1) and a(6) bit values must be mapped to b(1) (since a(1) and a(6) has mode value 1,so both a(1) and a(6) map to b(1))...
for suppose..a(1)=1 mod 5 = 1 and a(6)=6 mod 5 = 1.....so a(1) and a(6) has same mod values.now a(1) and a(6) must map to b(1) since they have mod value 1..b(1) contains a(1) and a(6) values...i am not worried about the it values..i just want many to one mapping..b(1) must contain both bit values of a(1) and a(6)...
new_len = 576;
old_len = length(a);
mapped_index = 1 + mod((1:old_len) - 1, new_len);
b = accumarray( mapped_index(:), a(:), [new_len 1], @(L) {unique(L.')} ) .';
You would then need to reference b{1} to get the various numbers stored at location b(1)
Guillaume
Guillaume am 21 Mär. 2017
Isn't this more or less the same as what I proposed over a day ago and has been completely ignored?
Walter Roberson
Walter Roberson am 21 Mär. 2017
Yup. I generalized slightly. I also arranged the bits in a different order that seemed more natural. But the biggest change is unique() the bits to emphasize that many-to-one mappings are unordered unless order is specifically requested (in which case it becomes a different scenario.)
Jyothi Alugolu
Jyothi Alugolu am 22 Mär. 2017
Thank you Walter Roberson and Guilaume....
Jyothi Alugolu
Jyothi Alugolu am 27 Mär. 2017
Hello, i have one more question...now how to apply FFT on b( above generated bit string)...
Jyothi Alugolu
Jyothi Alugolu am 27 Mär. 2017
while applying FFT on 'b', there was an error "Undefined function 'fft' for input arguments of type 'cell'"...can u tell me how to apply FFT on dis 'b'...
Guillaume
Guillaume am 27 Mär. 2017
I would suggest you start a new question, explaining in a lot more details what it is you want to do.
Applying a fft on a bit string does not make much sense. Applying a fft on your multi-valued b makes absolutely no sense.
Jyothi Alugolu
Jyothi Alugolu am 27 Mär. 2017
Normally we have to apply FFT on binary string 'b' which is of double,but our generated binary string is of type cell..so,we used cell2mat function to convert input argument of type cell to double..but,there is a problem i.e., the cell with 2 values of generated binary string is being splitted (like if a cell(be 4) in 'b' has [0,1] values,then after using Cell2mat function the 4th cell is having 0 value and 5th cell is having 1 value)...but, i dont want these 2 values to be splitted...i want these 2 values to be within a cell to apply FFT..if it is not possible to apply FFT on this 'b' without using cell2mat function,can you please tell me how to overcome this problem...
Walter Roberson
Walter Roberson am 27 Mär. 2017
What you ask for is not possible. It is meaningless to apply fft to a many-to-one mapping.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Guillaume
Guillaume am 20 Mär. 2017

0 Stimmen

Is this what you're after? (I'm unclear on the result you want to obtain)
a = randi([0 1], 756, 1); %random demo data
b = randi([0 1], 576, 1); %does the content of b matter?
b = accumarray(mod(0:numel(a)-1, numel(b))'+1, a, [], @(bits) {bits})

Kategorien

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by