필터 지우기
필터 지우기

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 CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by