How to terminate a spmd loop

조회 수: 2 (최근 30일)
Star
Star 2018년 12월 19일
I have a spmd program as shown below:
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);
title('waveform');
end
It manage to run until the final bit, but it has problem in terminating the spmd loop. Means it could not display the waveform. It went back to labindex 1 and cause the error below:
Error detected on worker 1.
Attempted to access x(7.30154e+06); index out of bounds because numel(x)=7301528.
Any idea on the solution? Thank you.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Parallel Computing Fundamentals에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by