MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Thread Subject: How to split the matrix evenly spaced rows

 Subject: How to split the matrix evenly spaced rows From: Sum Nguyen Date: 17 Aug, 2012 15:35:10 Message: 1 of 5 I have matrix(A) with 12x4 like this: A =     1.7639 0.9502 0.7639 0.9172     2.7984 0.7894 0.9357 0.7727     3.9357 0.7727 0.7593 0.7581     4.9344 0.7593 0.7455 0.9357     5.7639 0.9502 0.7639 0.9172     6.7984 0.7894 0.9357 0.7727     7.9357 0.7727 0.7593 0.7581     8.9344 0.7593 0.7455 0.9357     9.7639 0.9502 0.7639 0.9172    10.7984 0.7894 0.9357 0.7727    11.9357 0.7727 0.7593 0.7581    12.9344 0.7593 0.7455 0.9357 And I want to split it to matrix B like this: B =     1.7639 0.9502 0.7639 0.9172     4.9344 0.7593 0.7455 0.9357     7.9357 0.7727 0.7593 0.7581     10.7984 0.7894 0.9357 0.7727 Could anyone help me please?
 Subject: How to split the matrix evenly spaced rows From: Stan Date: 17 Aug, 2012 16:16:10 Message: 2 of 5 "Sum Nguyen" wrote in message ... > I have matrix(A) with 12x4 like this: > A = > 1.7639 0.9502 0.7639 0.9172 > 2.7984 0.7894 0.9357 0.7727 > 3.9357 0.7727 0.7593 0.7581 > 4.9344 0.7593 0.7455 0.9357 > 5.7639 0.9502 0.7639 0.9172 > 6.7984 0.7894 0.9357 0.7727 > 7.9357 0.7727 0.7593 0.7581 > 8.9344 0.7593 0.7455 0.9357 > 9.7639 0.9502 0.7639 0.9172 > 10.7984 0.7894 0.9357 0.7727 > 11.9357 0.7727 0.7593 0.7581 > 12.9344 0.7593 0.7455 0.9357 > > And I want to split it to matrix B like this: > > B = > 1.7639 0.9502 0.7639 0.9172 > 4.9344 0.7593 0.7455 0.9357 > 7.9357 0.7727 0.7593 0.7581 > 10.7984 0.7894 0.9357 0.7727 > > Could anyone help me please? > ----------------------------X------------------------ This is pretty easy, using a loop. If you want to extract every 3 rows from A and put them into B, then: n=3; %interval between required rows for ii = 1:n      B = A(1:n:end,:); end ----------------------------X------------------------ PS: I am sure that this can be done without a loop......using 1 or 2 lines of code. Just wait and see if someone else posts this.
 Subject: How to split the matrix evenly spaced rows From: Bruno Luong Date: 17 Aug, 2012 16:21:14 Message: 3 of 5 "Stan" wrote in message ... > > n=3; %interval between required rows > for ii = 1:n > B = A(1:n:end,:); > end > ----------------------------X------------------------ Why the loop is needed at all??? Bruno
 Subject: How to split the matrix evenly spaced rows From: Stan Date: 17 Aug, 2012 16:27:07 Message: 4 of 5 "Stan" wrote in message ... > If you want to extract every 3 rows from A and put them into B, then: > > n=3; %interval between required rows > for ii = 1:n > B = A(1:n:end,:); > end > ----------------------------X------------------------ Actually, the loop I posted is not required. Here is the code that you need: n=3; B = A(1:n:end,:); Sorry for the confusion.
 Subject: How to split the matrix evenly spaced rows From: Sum Nguyen Date: 18 Aug, 2012 12:21:06 Message: 5 of 5 "Sum Nguyen" wrote in message ... > I have matrix(A) with 12x4 like this: > A = > 1.7639 0.9502 0.7639 0.9172 > 2.7984 0.7894 0.9357 0.7727 > 3.9357 0.7727 0.7593 0.7581 > 4.9344 0.7593 0.7455 0.9357 > 5.7639 0.9502 0.7639 0.9172 > 6.7984 0.7894 0.9357 0.7727 > 7.9357 0.7727 0.7593 0.7581 > 8.9344 0.7593 0.7455 0.9357 > 9.7639 0.9502 0.7639 0.9172 > 10.7984 0.7894 0.9357 0.7727 > 11.9357 0.7727 0.7593 0.7581 > 12.9344 0.7593 0.7455 0.9357 > > And I want to split it to matrix B like this: > > B = > 1.7639 0.9502 0.7639 0.9172 > 4.9344 0.7593 0.7455 0.9357 > 7.9357 0.7727 0.7593 0.7581 > 10.7984 0.7894 0.9357 0.7727 > > Could anyone help me please? > Thanks everybody for the answer!