MATLAB: Do I receive error ‘”plotFcns” must be a row cell array of plot function names’ in compiled spplication if perceptron is used as classifier for training Neural Network

compilerMATLAB CompilerNetworkneuralperceptronplotconfusionplotfcnsplotperformplottrainstate

If perceptron is used as classifier in "train" function to train neural network, the program works fine in MATLAB but throws the following error in compiled application-
Error using network/subsasgn>network_subsasgn (line 551)
"plotFcns" must be a row cell array of plot function names.
Error in network/subsasgn (line 10)
Error in perceptron>create_network (line 128)
Error in perceptron (line 74)
Error in testnn (line 3)
nnet:subsasgn:Property
This does not happen when other networks are trained.
The Compiler Support page says that most command line functionality, including functions for training neural networks are supported by MATLAB Compiler.
"perceptron" is also a command line function in Neural Network and must be supported by MATLAB Compiler.

Best Answer

In the file "perceptron.m" from the Neural Network toolbox, the function "create_network" returns a network object with the property "plotFcns" defined as {'plotperform','plottrainstate','plotconfusion'}.  Downstream these strings are referenced as function names.  Since they are just strings in the code, there is no way for the dependency analyzer to pick them up as dependencies.
A workaround for this issue is to add these dependencies manually using function "pragma".
Add the following line in the beginning of your file that uses "perceptron" function.
%#function plotperform plottrainstate plotconfusion