フィルターのクリア

fundamental principle of multiplication

2 ビュー (過去 30 日間)
a
a 2013 年 10 月 11 日
コメント済み: a 2013 年 10 月 14 日
i have 4 numbers as a row vector, p=[ 1 -1 j -j ];
Now, total number of different 4 digit numbers formed using elements of "p" is 4^4=256
Thus i need a 256*4 matrix.
How to create such a 256*4 matrix ?
  2 件のコメント
Image Analyst
Image Analyst 2013 年 10 月 12 日
What is a 4 digit number? Can you give an example of the first 6 rows of what you want at the result?
a
a 2013 年 10 月 12 日
編集済み: a 2013 年 10 月 12 日
@Image Analyst:
Here a 4 digit number is like,
1 1 1 1 ; 1 1 1 -1 ; 1 1 1 i ; 1 1 1 -i ; 1 1 -1 1; ... and so on(till 256 row vectors hence a 256x4 matrix).
first 6 rows of required data matrix are in text file attached.Please find the attached. (and the data need not be in that order).
But required matrix should be a "256x4 Complex double" having all rows unique.Any help ?

サインインしてコメントする。

採用された回答

Jos (10584)
Jos (10584) 2013 年 10 月 12 日
p = [ 1 -1 j -j ] ;
[a,b,c,d] = ndgrid(p) ;
M = [a(:) b(:) c(:) d(:)]
  1 件のコメント
a
a 2013 年 10 月 14 日
Thank you Jos (10584).

サインインしてコメントする。

その他の回答 (2 件)

Sean de Wolski
Sean de Wolski 2013 年 10 月 11 日
[xx,yy,zz,qq] = ndgrid('1234');
V = [xx(:) yy(:) xx(:) qq(:)]
  3 件のコメント
Cedric
Cedric 2013 年 10 月 12 日
編集済み: Cedric 2013 年 10 月 12 日
@Sean: I don't think that it works as expected..
>> size(unique(V, 'rows'))
ans =
64 4
a
a 2013 年 10 月 12 日
編集済み: a 2013 年 10 月 12 日
@cedric
yeah.
All rows are not unique.
In my case it should be all unique rows and matrix size should be 256x4 complex double.

サインインしてコメントする。


Cedric
Cedric 2013 年 10 月 12 日
編集済み: Cedric 2013 年 10 月 12 日
I guess that the following would work. I didn't think too much about it though and there must be a simpler or even trivial solution..
>> ID = mod(floor((0:255).' * 2.^[0:-2:-6]), 4) + 1 ;
>> p(ID)
Check
>> size(unique(ID, 'rows'))
ans =
256 4
  2 件のコメント
a
a 2013 年 10 月 12 日
@cedric:
thank you for your answer but yeah you are right that there must be a simpler or even trivial solution.
Cedric
Cedric 2013 年 10 月 12 日
編集済み: Cedric 2013 年 10 月 12 日
Just in case nobody proposes a better solution, the way this one works is comparable to the way you build tables of binary codes.. you build the first column as 01010101.., the second as 0011001100.., the third as 000011110000.., and so on. My solution does the same in base 4.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by