Matrix manipulation with matlab.

145 Views Asked by At

Is there a way for a given matrix:

$k= \left( \begin{array}{cccccc} a_1 & b_1 & c_1 & d_1 & e_1 & f_1\\ a_2 & b_2 & c_2 & d_2 & e_2 & f_2\\ a_3 & b_3 & c_3 & d_3 & e_3 & f_3\\ a_4 & b_4 & c_4 & d_4 & e_4 & f_4 \end{array} \right)$

to create two variables that have the values:

$a = a_1, b_1, c_1, a_2, b_2, c_2, a_3, b_3, c_3, a_4, b_4, c_4$

and

$b = d_1, e_1, f_1, d_2, e_2, f_2, d_3, e_3, f_3, d_4, e_4, f_4$

1

There are 1 best solutions below

0
On BEST ANSWER

Normal way:

>> a = k(:,1:floor(end/2));
>> a = a';
>> a = a(:)

a is the value of $a$, replacing k(:,floor(end/2)+1:end) in the line will give you $b$.

One line solution:

>> a = reshape(k(:,1:floor(end/2)),1,size(k(:))/2);