Error using codistributed/subsasgn (line 131) Assignment has more non-singleton rhs dimensions than non-singleton subscripts
<p>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: <br></p>

<pre><code>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       % =================&gt;&gt;&gt;    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
</code></pre>

<p>The result of <code>elnsum</code> and <code>elnproduct</code> and <code>eln</code> is just one value in <code>double</code> type.</p>

<p>and I get this error : </p>

<blockquote>
  <p>Error using forward_algo>(spmd) (line 45)<br>
      Error detected on workers 1 2.<br>
      Error in forward_algo(line 45)
      spmd</p>

<pre><code>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
</code></pre>
</blockquote>

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

<p>thank you</p>