help creating array from binary code

1 次查看(过去 30 天)
FRANCISCO
FRANCISCO 2013-9-25
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)

回答(1 个)

Image Analyst
Image Analyst 2013-9-25
编辑:Image Analyst 2013-9-25
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 个评论
Image Analyst
Image Analyst 2013-9-25
编辑:Image Analyst 2013-9-25
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 2013-9-25
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?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by