Hi,
Creating a class instance every time you want to call a method can indeed introduce overhead and reduce efficiency. You can try out the following to optimize the process:
- Use a persistent variable to store the class instance.
- This avoids the overhead of creating the class every time a method is called.
- If your class inherits from 'handle', it can be modified without needing to recreate it, which can be more efficient.
- Utilize directives like 'coder.varsize' and 'coder.inline' to help MATLAB optimize the code generation process.
Hope this helps.