Borrar filtros
Borrar filtros

How to make matrix?

1 visualización (últimos 30 días)
Saka Toshi
Saka Toshi el 4 de Sept. de 2016
Respondida: Star Strider el 4 de Sept. de 2016
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????

Respuestas (2)

Stephen23
Stephen23 el 4 de Sept. de 2016
Editada: Stephen23 el 4 de Sept. de 2016
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 el 4 de Sept. de 2016
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!

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by