フィルターのクリア

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 Center および File ExchangeLogical についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by