Working with Cell array (matrix) of structs

After some experiment I have ONE model as the result which is represented as struct:

>>models{1}
ans =
nstates: 3
type: 'mhmm'
nmix: 1
d: 1
cov_type: 'full'
init_type: 'manual'
pi_Prior: [3x1 double]
A_Prior: [3x3 double]
pi: [3x1 double]
A: [3x3 double]
mu: [52.9712 2.1608e+003 5.4774e+004]
Sigma: [1x1x3 double]
mixmat: [3x1 double]
loglike: [1x36 double]

So, after some series of experiments I have cell array (or matrix) of structs and the best way to get some fields of each model is:

nstates = cellfun(@(x) x.nstates, models(:), 'Uniform', 1); % for uniform output
logLikes = cellfun(@(x) x.logLikes, models(:), 'Uniform', 0); % for non-Uniform output, for expl. with %different length logLikes

if we have matrix of cells: models{nRuns, nModels} than we should use repmat at the end

logLikes = cellfun(@(x) x.nstates, models(:), 'Uniform', 0);
logLikes = reshape(logLikes,nRuns,nModels);

VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)

Tags: , , ,
| September 1st, 2011 | Posted in Matlab |

Leave a Reply

*