how to manage matrix construction?

2 ビュー (過去 30 日間)
janny
janny 2014 年 11 月 20 日
コメント済み: Guillaume 2014 年 11 月 25 日
hi guys
i need a code to construct this matrix, the code should allow the user to insert h1,h2...h(n-1)

採用された回答

Guillaume
Guillaume 2014 年 11 月 23 日
How about:
m = circshift(eye(numel(h) + 1), 1, 2)
m(end, 2:end) = h;
  2 件のコメント
janny
janny 2014 年 11 月 25 日
this one gave an error
??? Error using ==> circshift Too many input arguments.
Guillaume
Guillaume 2014 年 11 月 25 日
You must be using an older version of matlab then.
m = circshift(eye(numel(h) + 1), [0 1])
should work regardless of version

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

その他の回答 (1 件)

Star Strider
Star Strider 2014 年 11 月 20 日
Janny, meet compan. It generates the companion-form matrix you want.
  4 件のコメント
janny
janny 2014 年 11 月 25 日
the last line came in decimal.... it should be in binary,, it came as:
0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 1 8 10 7 1
how to make it in binary
Star Strider
Star Strider 2014 年 11 月 25 日
I have no idea what you’re doing. To make it binary with the randi function, change that line to:
len = 4; % Length of number string
h = randi([0 1],1,len);
To produce a binary string from a decimal number, use the dec2bin function.

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by