When I tried to use parfor to run my code, I always got the following error message (I defined the variable "red" at different places but still got this error message):
"An UndefinedFunction error was thrown on the workers for 'red'. This might be because the file containing 'red' is not accessible on the workers. Use addAttachedFiles(pool, files) to specify the required files to be attached. For more information see the documentation for 'parallel.Pool/addAttachedFiles'.
Undefined function or variable 'red'."
It is weird for me because I tried to define "red" at different place but still cannot fix this problem. Thanks a lot for your great help in advance.