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.
try % M-Hwcosim instructions here catch err = lasterror; % Release any Hwcosim instances try release(hwcosim_instance); end rethrow(err); end
The following command can be used to release all hardware co-simulation instances.
xlHwcosim('release'); % Release all Hwcosim instances