MATLAB: Am I unable to close the “xPC Target:Target Manager” window if I have the “xpctargetspy” window open

freezer12Simulink Real-Timesitplan_xpc_diagnosticstargetxcptgscopexpcxpctargetspy

Why am I unable to close the "xPC Target:Target Manager" window if I have the "xpctargetspy" window open?
For example:
1) I run 'xpctest' and open the 'xpcosc' model.
2) I change the simulation stop time on the model to 'inf'
3) I build and run the model
4) I then type at the MATLAB command line:
xpctargetspy
xpctgscope
5) When I type 'xpctgscope' two windows open (one of them is the 'xPC Target:Target Manager' ), and the following error message is shown in MATLAB:
??? Error using ==> set
An object and its uicontextmenu must be in the same figure.
Error in ==> D:\matlabR12\toolbox\rtw\targets\xpc\xpc\xpctgscope.m (create_contextmenupb)
On line 1605 ==> set(targetmanager.tgscpb(i),'UIContextMenu',targetmanager.contextmenu(i));
Error in ==> D:\matlabR12\toolbox\rtw\targets\xpc\xpc\xpctgscope.m
On line 106 ==> targetmanager=create_contextmenupb(targetmanager);
??? Attempt to reference field of non-structure array 'targetmanager'.
Error in ==> D:\matlabR12\toolbox\rtw\targets\xpc\xpc\xpctgscope.m
On line 28 ==> if targetmanager.dispmsg==0;
6) The only way I can close the 'xPC Target: Target Manager' window is by restarting MATLAB. If I try closing the window during the current MATLAB session I get the following error:
??? Error while evaluating figure CloseRequestFcn.
??? Attempt to reference field of non-structure array 'targetmanager'.
Error in ==> D:\matlabR12\toolbox\rtw\targets\xpc\xpc\xpctgscope.m
On line 28 ==> if targetmanager.dispmsg==0;

Best Answer

This problem has been fixed in xPC Target 1.2 (R12.1).
If you are using an older version, the only known workaround is to avoid having the 'xpctargetspy' window open prior to calling 'xpctgscope'.