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

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by Liaquat Ali
on 5 Feb 2013

Hallo every body have this matrix as

-4.1060 -0.0020 -4.1060 -0.0010 -4.1090 -0.0010 -3.9950 3.2950 -3.9950 3.2960 -4.0030 3.2930 -3.9940 3.2940 -3.9970 3.2970 -4.0010 3.2940 -4.1060 -0.0020 -4.1080 0 -4.1060 -0.0020 -4.1070 0 -4.1070 -0.0020 -4.1090 -0.0010 -3.9960 3.2930 -3.9970 3.2970 -4.0030 3.2960 -3.9970 3.2930 -4.0010 3.3050 -4.0020 3.2950 -4.1060 -0.0020 -4.1060 0 -4.1080 -0.0010 -4.1070 0 -4.1060 0 -4.1080 0 -3.9860 3.2860 -3.9970 3.2970 -4.0030 3.2950 -3.9950 3.2950 -3.9970 3.2970 -4.0030 3.2950 -4.1060 -0.0010 -4.1060 -0.0010 -4.1070 0 -4.1060 -0.0010 -4.1080 0 -4.1090 0.0010 -3.9980 3.2970 -3.9990 3.2970 -4.0030 3.2950 -3.9950 3.2950 -3.9970 3.2970 -4.0020 3.2950

which can be of any size, now i want to place all the values so that 3rd n 4 th coulm values comes under the end of 1st and 2nd row and so on all other tow pair columns values come under first n 2nd row

*No products are associated with this question.*

Answer by ChristianW
on 5 Feb 2013

Accepted answer

reshape([M(:,1:2:end) M(:,2:2:end)],[],2) % M is your Matrix

## 3 Comments

## José-Luis (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/62305#comment_127227

Please show an example of the desired output. Why do you want to do this? Is this homework?

## Jan Simon (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/62305#comment_127236

This cannot work for a [n x 6] matrix, because the result is not rectangular anymore. What do you want as output for:

## Liaquat Ali (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/62305#comment_127265

I have matrix like

f =

and i want the result to be f3 =

Thanks man i have already done it, I do not know whether i can post the answer my self or not ..............lols