change array into matrix

How to write a 4 values in rectangular grid a=[8 4 6 2]
it will become
a=
8 4
6 2

 Accepted Answer

Mischa Kim
Mischa Kim on 1 Feb 2014
Edited: Mischa Kim on 1 Feb 2014
Use the reshape command.
b = reshape(a,2,2)

3 Comments

This is ok.. how it will generate multiple numbers.. and the numbers are arranged into rectangular grid
Is this another question or are you confirming that the command does what you need it to do?
if i have a array with 50 numbers how it will be converted into rectangular matrix

Sign in to comment.

More Answers (0)

Categories

Asked:

on 1 Feb 2014

Commented:

on 1 Feb 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!