fundamental principle of multiplication
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Image Analyst
el 12 de Oct. de 2013
What is a 4 digit number? Can you give an example of the first 6 rows of what you want at the result?
Respuesta aceptada
Jos (10584)
el 12 de Oct. de 2013
p = [ 1 -1 j -j ] ;
[a,b,c,d] = ndgrid(p) ;
M = [a(:) b(:) c(:) d(:)]
Más respuestas (2)
Sean de Wolski
el 11 de Oct. de 2013
[xx,yy,zz,qq] = ndgrid('1234');
V = [xx(:) yy(:) xx(:) qq(:)]
Cedric
el 12 de Oct. de 2013
Editada: Cedric
el 12 de Oct. de 2013
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 comentarios
Cedric
el 12 de Oct. de 2013
Editada: Cedric
el 12 de Oct. de 2013
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.
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!