09.1.11

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)

07.28.11

Speeding up with repmat function (MEX version)

To run your matlab applications with repmat “functionality” faster, you can use MEX format of this function from Lightspeed matlab toolbox.
With the same initial conditions you can see “productivity boosting”. Figure 1 – with default repmat function. Figure 2 – with MEX version of repmat function.

matlab repmat

Fig.1 matlab default repmat function

MEX version repmat

Fig. 2 MEX version repmat

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

12.4.09

MCMC methods with a nice applete

Nice example at http://www.lbreyer.com/classic.html will demonstrate how MCMC works.

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