I'm running my code in parallel, my local profile has two cores. this code is Forward algorithm in hidden markov model. my code is here:

function [ eln_alpha ] = forward_algo( Obs,P,Pi_0 ,Q )
  parpool('local',2);
n = length(Pi_0);
T = length(Obs);
eln_alpha = zeros(n,T,'distributed');
parfor i1=1:n
    eln_alpha(i1,1) = elnproduct( eln(Pi_0(i1)) , eln(Q(i1,1)) );
end;
fi = T / numlabs;
 P ;
spmd       % =================>>>    line 45
    if labindex == 1
        labSend(P, 2);
        labSend(Q, 2);
    end
    if labindex == 2
        P = labReceive(1);
        Q = labReceive(1);
    end
    for t = ((labindex-1)*fi)+1:(labindex * fi)
        if t==1
            t=t+1;
        end
        for j=1:n
            logalpha = NaN;
            for i1=1:n
                logalpha = elnsum(logalpha , elnproduct( eln_alpha(i1,t-1) ,eln(P(i1,j)) ) );
            end;
            eln_alpha(j,t) = elnproduct(logalpha , eln( Q(j,t) ));
        end;
    end
end
end

The result of elnsum and elnproduct and eln is just one value in double type.

and I get this error :

Error using forward_algo>(spmd) (line 45)
Error detected on workers 1 2.
Error in forward_algo(line 45) spmd

Caused by:
Error using codistributed/subsasgn (line 131)
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Error using codistributed/subsasgn (line 131)
Assignment has more non-singleton rhs dimensions than non-singleton subscripts

As it appears I'm not trying to assign multiple values into a single left hand location to cause Assignment has more non-singleton rhs dimensions than non-singleton subscripts error. anybody can help?

thank you

0

There are 0 best solutions below