M-Hwcosim manages resources that it holds for a hardware co-simulation instance. It releases the held resources upon the invocation of the release instruction or when MATLAB exits. However, it is recommended to perform an explicit cleanup of resources when the simulation finishes or throws an error. To allow proper cleanup in case of errors, it is suggested to enclose M-Hwcosim instructions in a MATLAB try-catch block as illustrated below.
% M-Hwcosim instructions here
err = lasterror;
% Release any Hwcosim instances
try release(hwcosim_instance); end
The following command can be used to release all hardware co-simulation instances.
xlHwcosim('release'); % Release all Hwcosim instances