Running a UI based function on a separate worker.

Hey all, I have a matlab function that opens a user interactive window and takes some inputs from the user and does some calculation which are displayed only on interactive window itself(no outputs). The calculations take a lot of time so I tried running it as a batch but ended up with the following error,
The script or function that will be called on the worker must be a single string or function handle.
Any ideas as to what the problem might be? Just to be clear, I am calling a single function in the batch but that function in itself calls other functions.

回答(1 个)

Your slightly later Question http://www.mathworks.com/matlabcentral/answers/317430-input-argument-error-while-running-a-batch-function suggests that you were calling batch() incorrectly, but it is difficult for us to be sure as you did not post your code.

7 个评论

This is a different function. After your reply to the previous one I slightly changed the way I was calling the function. The function in a folder on a separate path . So the entire code is
addpath ~/MATLAB/folder1
funcHandle=@ folder1.folder2.func1
j=batch(funcHandle,0);
But this time I am not even seeing the UI window that opens up.
The syntax
@ folder1.folder2.func1
is not valid, not unless folder1 is created as a "package" and folder2 is created as a package within the first package. That would require that the directory structure be
+folder1/+folder2/func1.m
where the '+' are literal parts of the directory name.
You cannot use @ to create a function handle to an arbitrary location: other than with packages, you can only create handles to functions that are on your path.
My bad! These are package folders. I call the function in the same manner usually, so I know that it works.
I suggest experimenting with
funcHandle = @(x) folder1.folder2.func1(x)
That's exactly what I did just without the input argument because it doesn't need one. But when I ran a batch with that function all the GUI didn't open up at like it normally does.
Can you zip up your code and attach it?

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Desktop 的更多信息

提问:

2016-12-19

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by