0
$\begingroup$

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$

$\endgroup$
1
$\begingroup$

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);

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.