Prev: MEX 32 bit on 64 bit machine
Next: result of sum(LargeArray) changes from execution to execution
From: Jeff Nowak on 9 Aug 2010 08:27 I'm new to parfor and was hoping someone might be able to tell me what is wrong with this code. Matlab gives the following error. ??? Error: The variable lEmax in a parfor cannot be classified. See Parallel for Loops in MATLAB, "Overview". Error in ==> testparfor at 18 parfor iHit=1:nHits I think lEmax fits the description of a sliced output variable. Below is the test code. Any help is appreciated. Jeff nPool = 4; if matlabpool('size') == 0 matlabpool('open','local',nPool) end nfft = 214; freqBinsInd = 1:nfft; fs=2500000; nEmaxRows = 12; nHits = 50; timevals = 1:nHits; lEmax = []; lEmax(nEmaxRows,nHits) = sqrt(-1); parfor iHit=1:nHits ii = iHit; freqval = (-nfft/2+freqBinsInd(ii)-1)*fs/nfft; it = complex(randn(8,1),randn(8,1)); lEmax(1,iHit) = it(1); lEmax(2,iHit) = it(2); lEmax(3,iHit) = it(3); lEmax(4,iHit) = it(4); lEmax(5,iHit) = it(5); lEmax(6,iHit) = it(6); lEmax(7,iHit) = it(7); lEmax(8,iHit) = it(8); azel = [cos(rand(1));sin(rand(1))]*pi/180; lEmax(9,iHit) = mod(90-azel(1),360); lEmax(10,iHit) = azel(2); lEmax(11,iHit) = timevals(iHit); lEmax(12,iHit) = freqval; end
From: Steven_Lord on 9 Aug 2010 09:15 "Jeff Nowak" <nowak(a)ll.mit.edu> wrote in message news:RuS7o.1586$oF2.260(a)llnews... > I'm new to parfor and was hoping someone might be able to tell me what is > wrong with this code. Matlab gives the following error. > > ??? Error: The variable lEmax in a parfor cannot be classified. > See Parallel for Loops in MATLAB, "Overview". > > Error in ==> testparfor at 18 > parfor iHit=1:nHits > > > I think lEmax fits the description of a sliced output variable. > Below is the test code. Any help is appreciated. > > Jeff > > > nPool = 4; > if matlabpool('size') == 0 > matlabpool('open','local',nPool) > end > > nfft = 214; > freqBinsInd = 1:nfft; > fs=2500000; > > nEmaxRows = 12; > nHits = 50; > > timevals = 1:nHits; > > lEmax = []; > lEmax(nEmaxRows,nHits) = sqrt(-1); > > parfor iHit=1:nHits > ii = iHit; > freqval = (-nfft/2+freqBinsInd(ii)-1)*fs/nfft; > it = complex(randn(8,1),randn(8,1)); > > lEmax(1,iHit) = it(1); > lEmax(2,iHit) = it(2); *snip* As written, IEmax is not a sliced variable. The criteria that a variable must satisfy to be sliced are: http://www.mathworks.com/access/helpdesk/help/toolbox/distcomp/brdqtjj-1.html#bq_tcng-1 IEmax satisfies the "Type of First-Level Indexing", "Form of Indexing", and "Shape of Array" criteria. Where it fails is in the "Fixed Index Listing" criterion, as you have one instance of IEmax being indexed with indices (1, iHit) and another instance with (2, iHit). Move the construction of azel up above the assignment to IEmax and construct the vector of values that you want to assign into IEmax as a temporary variable vectorRHS, then use: IEmax(:, iHit) = vectorRHS; % or IEmax(1:nEmaxRows, iHit) = vectorRHS; as the only assignment to IEmax in the loop and it should satisfy all four of those criteria. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
Pages: 1 Prev: MEX 32 bit on 64 bit machine Next: result of sum(LargeArray) changes from execution to execution |