سؤال

I have a y in the following format (printed):

y(:,:,1) =

     1     0     0
     0     1     0
     0     0     1


y(:,:,2) =

    0.9263    0.3468    0.1474
   -0.3468    0.6314    0.6936
    0.1474   -0.6936    0.7052


y(:,:,3) =

    0.7595    0.4380    0.4811
   -0.4380   -0.2027    0.8760
    0.4811   -0.8760    0.0378

[...]

y(:,:,19) =

    0.6071   -0.1174    0.7859
    0.1174   -0.9646   -0.2349
    0.7859    0.2349   -0.5717


y(:,:,20) =

    0.7189   -0.4086    0.5622
    0.4086   -0.4055   -0.8172
    0.5622    0.8172   -0.1244

How can I convert it to:

y(:,:,1) =

     1     0     0


y(:,:,2) =

    0.9263    0.3468    0.1474


y(:,:,3) =

    0.7595    0.4380    0.4811

[...]

y(:,:,19) =

    0.6071   -0.1174    0.7859


y(:,:,20) =

    0.7189   -0.4086    0.5622

(To get the first, second and third row for each 20 steps and store it in another variable.)

هل كانت مفيدة؟

المحلول

If you mean "how to get the first row", you can do it like this:

other_matrix = y(1,:,:)

نصائح أخرى

As @blackbird said,

Access your matrix as y(1,:,1),y(1,:,2)......y(1,:,19),y(1,:,20)

The documentation explains how to use the colon operator (:) to get the first row.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top