Reconstruct 2D array from single values

I am sending data over from labview to matlab (with javasockets) The values I am sending is a 2d array, and they will be sent one by one to matlab. I want to receive these values, and be able to reconstruct the same original array, with the same dimensions. How can I do this? I have looked at reshape(), but the output array is not what I expect. For example if I receive 8 numbers: 1,2,3,4,5,6,7,8
I want to put them into a 2x4 array : [1,2,3,4 ; 5,6,7,8]
I know the mxn dimensions the output array in advance.
Thanks

답변 (1개)

Roger Stafford
Roger Stafford 2013년 12월 12일

0 개 추천

After doing an appropriate reshape, do a transpose to achieve that result:
reshape([1 2 3 4 5 6 7 8],4,2).'
(= [1,2,3,4 ; 5,6,7,8])

카테고리

도움말 센터File Exchange에서 Cell Arrays에 대해 자세히 알아보기

질문:

g
g
2013년 12월 12일

답변:

2013년 12월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by