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