how to perform Many to one mapping
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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 件のコメント
Guillaume
2017 年 3 月 20 日
k cannot be j mod 576 as this would produce zero indices. k could be ((j-1) mod 576)+1
採用された回答
Walter Roberson
2017 年 3 月 20 日
Afterwards, should b(1) be assigned the value of a(1), or should it be assigned the value of a(577) ?
17 件のコメント
Jyothi Alugolu
2017 年 3 月 20 日
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
2017 年 3 月 20 日
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
2017 年 3 月 20 日
編集済み: Walter Roberson
2017 年 3 月 20 日
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
2017 年 3 月 20 日
編集済み: Walter Roberson
2017 年 3 月 20 日
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
2017 年 3 月 20 日
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)...
Walter Roberson
2017 年 3 月 20 日
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
2017 年 3 月 20 日
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
2017 年 3 月 21 日
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)...
Walter Roberson
2017 年 3 月 21 日
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
2017 年 3 月 21 日
Isn't this more or less the same as what I proposed over a day ago and has been completely ignored?
Walter Roberson
2017 年 3 月 21 日
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
2017 年 3 月 22 日
Thank you Walter Roberson and Guilaume....
Jyothi Alugolu
2017 年 3 月 27 日
Hello, i have one more question...now how to apply FFT on b( above generated bit string)...
Jyothi Alugolu
2017 年 3 月 27 日
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
2017 年 3 月 27 日
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
2017 年 3 月 27 日
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
2017 年 3 月 27 日
What you ask for is not possible. It is meaningless to apply fft to a many-to-one mapping.
その他の回答 (1 件)
Guillaume
2017 年 3 月 20 日
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})
カテゴリ
ヘルプ センター および File Exchange で Tables についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
