Assigning values to a matrix in a particular way for an algorithm

조회 수: 1 (최근 30일)
Hi I need to construct a (n,m) matrix like :
x(0) x(-1) x(-2)..........
x(1) x(0) x(-1)..........
x(2) x(1) x(0)...........
.............................
.............................
x(n-1) x(n-2) x(n-m)
x(n)is an input signal- x(0),x(1),x(2)....x(n-1) which will be generated by rand command.
I need this matrix for an algorithm.
Can anyone show me how to assign these input values in this matrix form?
And what about x(-1), x(-2) etc in the very first stage? Should they be kept zero?
Thank you

채택된 답변

Guillaume
Guillaume 2015년 3월 15일
Your matrix is a toeplitz matrix which you can generate with the toeplitz command.
As to your question "And what about x(-1), x(-2) etc in the very first stage? Should they be kept zero?". How should we know? It's your algorithm, hence your decision to make. Assuming you want 0:
x = rand(1, 5)
m = toeplitz(x, [x(1) zeros(1, numel(x)-1)])
%note that if you don't mind the warning message
%m = toeplitz(x, zeros(size(x)))
%works just the same

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by