Borrar filtros
Borrar filtros

help creating array from binary code

1 visualización (últimos 30 días)
FRANCISCO
FRANCISCO el 25 de Sept. de 2013
I have this sequence with your right numbering indicating the order.
0 (1) 0 (2) 0 (3) 1 (4) 1 (5) 0 (6) 0 (7) 0 (8) 0 (9) 0 (10) 1 (11) 0 (12) 0 (13) 0 (14) 0 (15)
  1 (16) 0 (17) 0 (18) 1 (19) 1 (20).
As would be the code to create the following matrix?
0 (18) 1 (19) 1 (20)
0 (15) 0 (17) 1 (19)
0 (12) 0 (15) 0 (18)
0 (9) 0 (13) 0 (17)
0 (6) 1 (11) 1 (16)
0 (3) 0 (9) 0 (15)

Respuestas (1)

Image Analyst
Image Analyst el 25 de Sept. de 2013
Editada: Image Analyst el 25 de Sept. de 2013
out = zeros(6,3); % Initialize
% First column
out(:,1) = inputMatrix(18:-3:3,1);
% Second column
out(:,2) = inputMatrix(19:-2:9, 2);
% Third column
out(:,3) = inputMatrix(20:-1:15, 3);
It would be easy to generalize this for different sized input matrix, but you haven't said you need to do that (plus it's easy enough for you to figure out yourself).
  3 comentarios
Image Analyst
Image Analyst el 25 de Sept. de 2013
Editada: Image Analyst el 25 de Sept. de 2013
Like I said, it's really easy so I'm pretty sure you can do it. This may help:
L = length(inputMatrix);
out(:,1) = inputMatrix(L-2:-3:1,1);
See if you can get the rest. I can't really do it for you because you didn't say what's constant in the output matrix - the number of rows or the number of columns, or if both vary, how you decide on the number of rows and columns.
FRANCISCO
FRANCISCO el 25 de Sept. de 2013
if true % code %s= sequence numbered 1 to 20 n=length(s);
d=3; %in this case is 3, but may be 4, 5, .....
end Now I do not know how to continue because the dimension of the matrix do not match what is calculated in matlab
How to make so that the dimension of the matrix automatically calculates it me?, Ie you enter your order will:
out = zeros (6,3);% Initialize
But this is as it should be to do it automatically?

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by