如何终止spmd循环

时间:2018-12-19 06:48:14

标签: matlab loops spmd

我有一个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.

对解决方案有任何想法吗?谢谢。

0 个答案:

没有答案