Refer to GPT and own ideas, according to AttributeError: module 'EX_4' has no attribute 'initialize', probably because the initialize function is not defined in the EX_4 module. The problem may be caused by the failure to include the initialize function in the package, or the function name may have been renamed.
You can check to see if the initialize function is included in the EX_4 module. If it is not, you need to make sure it is included in the package. If so, the function name may have been renamed. You need to check to see if there is an alias that specifies the initialize function name when packaging.
If you are sure that the initialize function has been properly packaged and the function name has not been renamed, then you can try using dir(EX_4) to view all properties and methods included in the EX_4 module to ensure that the initialize function has been properly imported. If the initialize function does not appear on the list, you may need to repackage the code to fix the problem.
Try to change EX_4.initialize() to EX_4.EX_4.initialize_runtime(), i.e.
my_EX_4 = EX_4.EX_4.initialize_runtime()
This is because after compiling MATLAB code into a Python module using the MATLAB Compiler SDK, the name of the module is actually ex_4.ex_4, not simply EX_4. Therefore, you need to use EX_4.EX_4 to call the functions in the module.
If the problem still cannot be resolved, it is recommended to check the MATLAB Compiler SDK compiled module for any initialize functions, or to check the module documentation to determine the correct method to call.