Help to write a simple codë to split vector to subvectors

Hello,
probably this question is quiet simple for this forum, but I decided to ask you!
I have Y=[Y1;Y2;Y3;Y4;Y5;Y6,...,Ym], where m is multiple of 3.
I'd like to obtain for i=1:(m/3);
y1=[Y1;Y2;Y3], y2=[Y4;Y5;Y6],....
I will appreciate any suggestion and please don't be very critical to this simple issue!
Thank you in advance!

 Akzeptierte Antwort

Honglei Chen
Honglei Chen am 7 Feb. 2012
Are all Y1 through Ym equal length. If so, assume the length is N, then you can do
y = reshape(Y,3*N,[])
and each column in y corresponds to one of the subvector you want.

1 Kommentar

Thank you for teh help!The "reshape" function is suitable!
Regards

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 7 Feb. 2012

Bearbeitet:

am 3 Okt. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by