errors occurring when implementing ALO based FOPID controller code in a simulation using MATLAB function block

5 vues (au cours des 30 derniers jours)
I am using Ant-Lion Optimization (ALO) to improve the performance of FOPID controllers in a microgrid simulation. While implementing the ALO code along with FOPID in simulation, I am getting some errors like "Errors occurred during parsing of MATLAB function", "Function call failed" and so on. Code itself does not have any errors but they occur only when combining with simulation. What could be the solution for this?
I am using FOMCON and Ant-Lion Optimizer toolboxes.

Réponses (1)

Akanksha
Akanksha le 29 Août 2025
These errors usually occur because Simulink MATLAB Function blocks have stricter requirements and do not support all MATLAB commands or toolbox functions, even if your code runs fine in the MATLAB workspace. As a result, features from ALO or FOMCON might not work directly inside simulation blocks.
To help you move forward, below listed are a few practical steps you can try:
  1. Check for Unsupported Functions: Review your code for any functions not supported for code generation or simulation in MATLAB Function blocks.
  2. Use Interpreted MATLAB Function Block: If possible, use the "Interpreted MATLAB Function block" instead of the standard MATLAB Function block. This block is less restrictive but may be slower.
  3. Precompute Parameters: Run the ALO optimization in the MATLAB workspace first, store the optimized FOPID parameters, and then use these values as constants in your Simulink model, rather than running the optimizer during simulation.
  4. Check Toolbox Compatibility: Make sure both FOMCON and Ant-Lion Optimizer functions are compatible with Simulink and, if needed, with code generation. Some FOMCON features are not supported in Simulink blocks.
  5. Debugging: Use "disp" statements or break your code into smaller parts to see exactly where the error occurs. Sometimes, splitting the optimization and simulation into separate steps helps isolate the issue.
If you need more details, the following resources may be helpful:
https://www.mathworks.com/help/simulink/ug/functions-supported-for-code-generation--alphabetical-list.html lists all MATLAB functions that can be used inside Simulink's MATLAB Function blocks and are compatible with code generation.
https://www.mathworks.com/help/simulink/slref/interpretedmatlabfunction.html documentation explains the Interpreted MATLAB Function block, which allows running MATLAB code in Simulink with fewer restrictions than the standard MATLAB Function block.
https://fomcon.net/docs/latest/user_guide.html#simulink-interface section of the FOMCON documentation details how to integrate FOMCON features with Simulink models.
Hope this helps!

Catégories

En savoir plus sur Modeling dans Help Center et File Exchange

Tags

Produits


Version

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by