Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to slice array of structures into rows, not columns?

Consider the following.

a(1).x = [1 2 3];
a(2).x = [4 5 6];

[a.x] will give you [1 2 3 4 5 6].

How to easily get [1 2 3; 4 5 6]. I.e. without using reshape, for example.

P.S. The syntax [a.x;] would be cool to have.

like image 740
Roman Byshko Avatar asked Dec 27 '22 07:12

Roman Byshko


1 Answers

You can do it using vertcat:

vertcat(a.x)

ans =

 1     2     3
 4     5     6
like image 57
wakjah Avatar answered Jan 04 '23 22:01

wakjah