How can I read an external file in Simulink to get some parameters in a way supported for code generation?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a Simulink model that I use to generate standalone code for embedded use (GRT target).
I need some parameters to perform calculations inside a subsystem. I do not want to provide them through input ports, but with an external file (.CSV, .TXT or other) as this subsystem shall have the same ports of other blocks that do not need those specific parameters.
The options I found are:
- "From File" block accepts only .MAT files and for code generation it requires timeseries signals (unconvenient for my goal if dealing with lots of parameters);
- "From Spreadsheet" block accepts excel and .CSV files but does not support generating code that involves building ERT or GRT targets;
- "Matlab Function" block with fopen command is supported for code generation. A writing procedure of an external file is successfully supported for standalone code generation. However I cannot find a compatible way to read an external file: with fread it is possible to read data but as I need fscanf, sscanf, textscan, xlsread, regexp or fgetl, they are not supported.
Is there a good way to resolve the issue?
0 commentaires
Réponses (1)
Manjunath Bhimalli
le 7 Août 2019
From your problem statement it shows that you have a model whic looks below and need to add few parameters specific to only for SubSytsem_A/B and do not want to add them as new inputs.
Solution: If this is the case make them as configurable and define thier structure in new xyz.m file and include as preload function, read/use them via constant blocks in your logic(SubSytsem_A/B) wherver required.
0 commentaires
Voir également
Catégories
En savoir plus sur Deployment, Integration, and Supported Hardware dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!