Effacer les filtres
Effacer les filtres

How to make matrix?

1 vue (au cours des 30 derniers jours)
Saka Toshi
Saka Toshi le 4 Sep 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????

Réponses (2)

Stephen23
Stephen23 le 4 Sep 2016
Modifié(e) : Stephen23 le 4 Sep 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 le 4 Sep 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!

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by