What is the meaning of this simple 1 line matlab code?
조회 수: 38 (최근 30일)
이전 댓글 표시
X = [x, zeros(1,n)];
x is a 1xN matrix.
댓글 수: 0
답변 (1개)
Alok Nimrani
2018년 4월 6일
Hi Minsoo Kim,
zeros(1,n) creates a 1xn vector of zeros i.e.
>> zeros(1,5)
ans =
0 0 0 0 0
You can read more about ‘zeros’ at the following link: https://www.mathworks.com/help/matlab/ref/zeros.html
Now, ‘x’ is a 1xn vector and the operation being performed is:
>> X = [x zeros(1,n)];
Here, ‘[ ]’ is the matrix constructor operator and when the elements within the brackets are separated by space, the resulting matrix is a row-wise concatenation of the elements. So, the above operation is basically a row-wise concatenation of ‘x’ and ‘zeros(1,n)’. Check the following code as an example:
>> x = ones(1,5)
x =
1 1 1 1 1
>> X = [x zeros(1,5)]
X =
1 1 1 1 1 0 0 0 0 0
For more information about the matrix constructor operator '[ ]', you can check the following link: https://www.mathworks.com/help/matlab/math/creating-and-concatenating-matrices.html#f1-84906
Hope this clears your query.
Thanks.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!