Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cryptic Error message in parfor

7 views
Skip to first unread message

Chris Hager

unread,
Apr 5, 2009, 6:11:01 PM4/5/09
to
Dear Listers
using parfor gives me some headaches and the error message I get does not make any sense. I have a GUI and when I press the start button I want to run a certain number of simulations in parfor mode. During the run the user can check a box to display on the fly the results in graphs or not (faster). M-Lint in general seems to be happy but tells me in Line 878 that "variable 'handles' is indexed but not sliced..." which does not make sense to me. Here is the code and the error (R2009a).

%hit Start Button
matlabpool open % open 8 workers
letssee=[1:10] %just wanted to know if matlabpool opens correctly

Line 594: parfor x=1:100
.
Line 878: switch get(handles.check_Watch,'Value'); % check for "Watch Run" box
.
end


Here is the result:
----------------------------------------------------
letssee =

1 2 3 4 5 6 7 8 9 10 % that works but after that...

??? Error using ==> parallel_function at 594
Error in ==> myFile>(parfor body) at 878
Invalid handle object.

Error in ==> myFile>push_Start_Callback at 749
parfor x = 1:100 % Loop through each t-T Path

Error in ==> gui_mainfcn at 96
feval(varargin{:});

Error in ==> myFile at 42
gui_mainfcn(gui_State, varargin{:});

??? Error while evaluating uicontrol Callback
---------------------------------------------------

I have no idea why parfor is so unhappy with calls to an object handle in a GUI. I got rid of that call but then it hangs up on the next reference to a handle when I want to plot stuff

axes(handles.axes_PlotLeft)
hl = line(t_Path_all(:,x),T_Path_all(:,x));
...

Any ideas on that would be highly appreciated.

Thanks

Chris

Edric M Ellis

unread,
Apr 7, 2009, 3:31:04 AM4/7/09
to
"Chris Hager" <ha...@ku.edu> writes:

> using parfor gives me some headaches and the error message I get does not make
> any sense. I have a GUI and when I press the start button I want to run a
> certain number of simulations in parfor mode. During the run the user can
> check a box to display on the fly the results in graphs or not
> (faster). M-Lint in general seems to be happy but tells me in Line 878 that
> "variable 'handles' is indexed but not sliced..." which does not make sense to
> me. Here is the code and the error (R2009a).

Hi Chris,

I think the root of the problem you're having here is that your code uses a
handle within the body of a PARFOR loop. Unfortunately, because the body of the
PARFOR loop is executed by a separate MATLAB process, we cannot keep handle data
types, or HG handles (such as figure, axis and uicontrol handles) in sync across
the boundary between serial and parallel code execution. Likewise, the MATLAB
processes executing the body of your PARFOR loop do not have access to the
figures created by your "client" MATLAB, and so they cannot update graphics
during the execution of a PARFOR loop.

Currently, your code appears to do stuff like this:

parfor ....
switch get(handles.check_Watch, 'Value') ....
end

I would recommend moving the "get" call to before the loop, like so:

watchVal = get(handles.check_Watch, 'Value');
parfor ....
switch watchVal ....
end

Cheers,

Edric.

Chris Hager

unread,
Apr 9, 2009, 9:52:01 AM4/9/09
to
Edric M Ellis <eel...@mathworks.com> wrote in message <ytweiw4...@uk-eellis-deb4-64.mathworks.co.uk>...


Dear Edric

Thanks a lot for the information, unfortunately this was not good news for me. The whole point of the GUI was to give the user the opportunity to check the model results on-the-fly and see the progress of the simulation via progress bar and timer. When reading through the documentation I already had a bad feeling about plots although the documentation seems to be vague about it and does not explicitly state that plot will not work (and I could not find anything about handles!?). I guess I have to sacrifice that functionality and let the model run "blind".
Anyway, I appreciate your reply.

Thanks
Chris

0 new messages