필터 지우기
필터 지우기

How to make matrix?

조회 수: 1 (최근 30일)
Saka Toshi
Saka Toshi 2016년 9월 4일
답변: Star Strider 2016년 9월 4일
How to make a matrix? This matrix A is made by vectors. Now, A is 3-dimension, A=[Y3,Y2,Y1]
These matrix are made by data vectors y.
Y3=y(3:end);Y2=y(2:end-1);Y1=y(1:end-2);
How to make this matrix A which has any dimensions????

답변 (2개)

Stephen23
Stephen23 2016년 9월 4일
편집: Stephen23 2016년 9월 4일
How to create matrices and arrays is explained in the MATLAB documentation:
In your code you might like to experiment with cat to create a 3D array:
cat(3,y(3:end),y(2:end-1),y(1:end-2))
You could also use reshape, but keep in mind that MATLAB works along columns and then rows.
(learning to avoid numbered variables is a good idea too).

Star Strider
Star Strider 2016년 9월 4일
If you’re interested in the minimum value of the length of the vector ‘y’ that will satisfy all these vectors, a little recreational algebra (substituting ‘L’ for end, the last element in the vector) gives:
L-2 - 1 = y
L-1 - 2 = y
L - 3 = y
———————————————
3*L-3 - 6 = y
3*(L-1) - 6 = y
(L-1) - 2 = y
———————————————
L - 3 = y
Add 1 because of the addressing conventions, and the minimum vector length ‘y’ = 4. Trivial, and possibly completely irrelevant, but fun!

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by