I have an array of classes (we'll call it a, size Mx1) that contains a property (feature) which holds a 1xN array. I'm trying to get a new matrix that is MxN which contains rows of each of the feature property of the objects. For example:
M = 3
N = 4
a(1,1).feature = [1 2 3 4]
a(2,1).feature = [5 6 7 8]
a(3,1).feature = [9 10 11 12]
then, given some function, the answer would end up as:
ans = [1 2 3 4; 5 6 7 8; 9 10 11 12]
Currently, I've been using the following:
ans = cell2mat({a.feature}')
however I feel there should be a way to do this without having to convert to a cell, switch the dimensions, and then convert to a matrix. Am I correct or would this be the best way to solve the issue? I haven't been able to find any such function in the documentation.