Context
At work, I built a graphical interface for registering images on several microscopy images. The Parallel Processing Toolbox is installed on the computer that I use (i.e. at work), so I can use spmd blocks to distribute work on computer cores.
First I create a codistributed array to split my array into smaller pieces:
spmd
DistributedCell = codistributed.cell(NumberFrames)
...
end
Everything is fine until I run the code on my own laptop on which the Parallel Processing Toolbox is not installed. Obviously, I cannot use blocks spmdand arrays with distributed distribution, so I wrote non-parallel code for registering images, which works equally well, but takes longer.
Problem
The problem I am facing is that the code in the blocks spmdneeds to be commented out when I use my home laptop, otherwise Matlab complains that:
MATLAB cannot determine whether "codistributed"
refers to a function or variable.
So, even if I check whether the PP toolbox is installed (or not), and use the condition to execute different commands, depending on whether it is or not, as follows:
%// Check for parallel toolbox installed
if ~isempty(ver('parallel'))
NON-PARALLEL code...
else
PARALLEL code...
spmd
PROBLEM HERE
DistributedCell = codistributed.cell(NumberFrames)
...
end
end
Matlab if , . , , , , ( ) , .
Matlab , , PP?
, - , .
Mac, (R2015a R2013a ).
:
, - . , Matlab , - . ( undefined function [...]), if/else. codistributed, Matlab.