Q:

how to roll two arrays of diffeent dimesnions into one dimensional array in python

I have two arrays (a,b) of different mXn dimensions
I need to know that how can I roll these two arrays into a single one dimensional array
I used np.flatten() for both a,b array and then rolled them into a single array but what i get is an array containg two one dimensional array(a,b)
a = np.array([[1,2,3,4],[3,4,5,6],[4,5,6,7]]) #3x4 array
b = np.array([ [1,2],[2,3],[3,4],[4,5],[5,6]]) #5x2 array

result = [a.flatten(),b.flatten()]
print(result)
[array([1, 2, 3, 4, 3, 4, 5, 6, 4, 5, 6, 7]), array([1, 2, 2, 3, ... 5, 6])]

In matlab , I would do it like this :
res = [a(:);b(:)]

Also, how can I retrieve a and b back from the result?

A:

Use ravel + concatenate:
>>> np.concatenate((a.ravel(), b.ravel()))
array([1, 2, 3, 4, 3, 4, 5, 6, 4, 5, 6, 7, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6])

ravel returns a 1D view of the arrays, and is a cheap operation. concatenate joins the views together, returning a new array.

As an aside, if you want to be able to retrieve these arrays back, you'll need to store their shapes in some variable.
i = a.shape
j = b.shape
res = np.concatenate((a.ravel(), b.ravel()))

Later, to retrieve a and b from res, 
a = res[:np.prod(i)].reshape(i)
b = res[np.prod(i):].reshape(j)

a
array([[1, 2, 3, 4],
       [3, 4, 5, 6],
       [4, 5, 6, 7]])

b 
array([[1, 2],
       [2, 3],
       [3, 4],
       [4, 5],
       [5, 6]])

