Borrar filtros
Borrar filtros

Structure of Strings

1 visualización (últimos 30 días)
Jay
Jay el 11 de Jul. de 2011
Hi!
I want to specify possible parameters for the naive bayes classifier. For this reason, I have created a structure with a field for each parameter and a matrix with possible values.
bayesPosParams.distribution = ['normal'; 'kernel'];
bayesPosParams.prior = ['empirical'; 'uniform'];
bayesPosParams.KSWidth = 'scalar';
bayesPosParams.KSSupport = ['unbounded'; 'positive'];
Unfortunately that does not work: ??? Error using ==> vertcat CAT arguments dimensions are not consistent.
All Strings need to have the same length. What would be the best possibility to specify the parameters nice and consistently?
Thanks in advance, Jay

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 11 de Jul. de 2011
bayesPosParams.distribution = {'normal'; 'kernel'};
bayesPosParams.prior = {'empirical'; 'uniform'};
bayesPosParams.KSWidth = 'scalar';
bayesPosParams.KSSupport = {'unbounded'; 'positive'};

Más respuestas (1)

Jay
Jay el 11 de Jul. de 2011
Hi Andrei!
Then every field would be a cell array, correct? What's the differences between this approach and using, my just discovered method, bayesPosParams.distribution = char('normal', 'kernel')?
I will want to operate on bayesPosParams with for-loops.
Thanks!
  6 comentarios
Jay
Jay el 12 de Jul. de 2011
right, i want to test all possible combinations of parameters.
only way i could think of is to do this with four nested for-loops. Probably very slow, but don't know how to do that else.
So I would for example want to iterate over all chararray-values of bayesPosParams.distribution, namely 'normal' and 'kernel'.
How do I do that?
Something like:
for dis = bayesPosParams.distribution{}
....
but this does not seem right either...
Andrei Bobrov
Andrei Bobrov el 12 de Jul. de 2011
dis - cell array, and may be any operation with 'dis', as with cellarrays

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by