From: Bruno on
The code is giving:


??? Error using ==> rdivide
Matrix dimensions must agree.

Error in ==> fit_mix_gaussian at 41
P = C ./ (Ic*sqrt(sig2)) .* exp( -((X*Ir - Ic*u).^2)./(2*Ic*sig2) );



Any thoughts?
Regards,
Marchesi
From: RAJATH on
"Bruno " <bruno.marchesi(a)gmail.com> wrote in message <hpvmns$89d$1(a)fred.mathworks.com>...
> The code is giving:
>
>
> ??? Error using ==> rdivide
> Matrix dimensions must agree.
>
> Error in ==> fit_mix_gaussian at 41
> P = C ./ (Ic*sqrt(sig2)) .* exp( -((X*Ir - Ic*u).^2)./(2*Ic*sig2) );
>
>
>
> Any thoughts?
> Regards,
> Marchesi

Its fine. Code is working properly.

Rajath
From: Greg Heath on
On Apr 26, 7:20 am, "RAJATH " <rajathb...(a)gmail.com> wrote:
> "Bruno " <bruno.march...(a)gmail.com> wrote in message <hpvmns$89...(a)fred.mathworks.com>...
> > The code is giving:
>
> > ??? Error using ==> rdivide
> > Matrix dimensions must agree.
>
> > Error in ==> fit_mix_gaussian at 41
> >     P = C ./ (Ic*sqrt(sig2)) .* exp( -((X*Ir - Ic*u).^2)./(2*Ic*sig2) );
>
> > Any thoughts?
> > Regards,
> > Marchesi
>
> Its fine. Code is working properly.
>
> Rajath

No. I agree with Bruno

??? Error using ==> ./
Matrix dimensions must agree.

Error in ==> C:\MATLAB6p5p1\work\GaussianMixture\gaussmix.m
On line 93 ==> P = C ./ (Ic*sqrt(sig2)) .* exp( -((X*Ir -
Ic*u).^2)./(2*Ic*sig2) );

Please compare the code you are running with the code you posted.

Hope this helps.

Greg
From: Greg Heath on
On Apr 27, 1:31 am, Greg Heath <he...(a)alumni.brown.edu> wrote:
> On Apr 26, 7:20 am, "RAJATH " <rajathb...(a)gmail.com> wrote:
>
>
>
>
>
> > "Bruno " <bruno.march...(a)gmail.com> wrote in message <hpvmns$89...(a)fred..mathworks.com>...
> > > The code is giving:
>
> > > ??? Error using ==> rdivide
> > > Matrix dimensions must agree.
>
> > > Error in ==> fit_mix_gaussian at 41
> > >     P = C ./ (Ic*sqrt(sig2)) .* exp( -((X*Ir - Ic*u).^2)./(2*Ic*sig2) );
>
> > > Any thoughts?
> > > Regards,
> > > Marchesi
>
> > Its fine. Code is working properly.
>
> > Rajath
>
> No. I agree with Bruno
>
> ??? Error using ==> ./
> Matrix dimensions must agree.
>
> Error in ==> C:\MATLAB6p5p1\work\GaussianMixture\gaussmix.m
> On line 93  ==>     P   = C ./ (Ic*sqrt(sig2)) .* exp( -((X*Ir -
> Ic*u).^2)./(2*Ic*sig2) );
>
> Please compare the code you are running with the code you posted.

This is the culprit:

sig2 = [1 1 1 1] * max(X).^2/M^2;

instead of

sig2 = ones(1,M) * max(X).^2/M^2;


However, I don't find this to be a reasonable initialization.

Try this (assumes a uniform distribution):

disp('INITIAL CENTERS VECTOR')

du = (max(X)-min(X))/(M+1);
u = linspace(min(X) +0.5*du,max(X)-0.5*du,M);

disp('INITIAL VARIANCE VECTOR')

sig2 = (du^2/12)*ones(1,M);

Hope this helps.

Greg