Как завершить цикл SPMD - PullRequest
       16

Как завершить цикл SPMD

0 голосов
/ 19 декабря 2018

У меня есть программа spmd, как показано ниже:

function [output,frequency] = spmdfunc(music)
fid = fopen( 'music.mp3', 'r', 'b'); 
x = uint8( fread(fid, 'ubit1')');

while ( a+31 <= numel(x) )   
   if( x(a:a+14) == syncword)
      poolobj = parpool (3);

         spmd
            if labindex == 1
               afr = dsp.AudioFileReader(%Content);

               while true
                  % Content
               end 

               labSend(2, [])
               release(afr)

             elseif labindex == 2
                while true
                   % Content

                      if isempty(frame)
                         labSend(3, []);
                      break
                      end
                 end
              else 
                 while true

                    if isempty (frame)          
                    break
                    end

                    length = numel(output(1,:));
                    output(1,length+1:PCM_length+1152) = [samples(1,:) samples(3,:)]; 
                    output(2,length+1:PCM_length+1152) = [samples(2,:) samples(4,:)]; 
                  end 

               end %labindex
            end %spmd end
         delete(gcp);  
       end 
       a = a + 1;   
    end
   %Display Waveform;
   figure(1);
   t=linspace(0,208,length(output(1,:)));
   plot(t,output);
end

Она может работать до последнего бита, но у нее проблемы с завершением цикла spmd.Означает, что он не может отображать форму волны.Он вернулся к labindex 1 и вызвал ошибку ниже:

Error detected on worker 1.
Attempted to access x(7.30154e+06); index out of bounds because numel(x)=7301528.

Есть идеи по поводу решения?Спасибо.

...