Borrar filtros
Borrar filtros

Change parameter dimensions with setparam method

5 visualizaciones (últimos 30 días)
Enzo Yacometti
Enzo Yacometti el 13 de Feb. de 2024
Respondida: Shivam Lahoti el 14 de Feb. de 2024
Hello, I’m building a Simulink RT app with App Designer and have the following issue. When I build the model, it compiles correctly and I assume that the target computer (speedgoat) compiles the data dictionary with all the parameters to run the model. The issue is I would want to update a Simulink.Parameter, which is an array, to a new value with different dimensions. The method to set new values on the target is “setparam()” but it seems to only access its value, not the rest of the fields (like dimension). How can I achieve what I’m looking for? Unfortunately for privacy reasons I cant share my model but I think the question is clear.

Respuestas (1)

Shivam Lahoti
Shivam Lahoti el 14 de Feb. de 2024
Hi Enzo,
From what I understand, you wish to change both the values and the dimensions of a parameter in your real-time application (RT-app). However, for real-time applications or when using real-time hardware like Speedgoat, the dimensions of parameters must be fixed at the time of compilation and cannot be altered during execution. If you need to adjust the dimensions for a real-time application, the typical process would involve modifying the model to accommodate the new dimensions and then recompiling and redeploying the application.
Nevertheless, there is a potential workaround that involves pre-allocating the parameter to its maximum size, if that approach is suitable for your situation. Please follow these steps:
  1. Pre-allocate the Parameter: Define the Simulink.Parameter with the maximum size you expect to use.
  2. Use a Subset: Only use the subset of the parameter that you need for a particular operation.
  3. Control with Additional Parameters: Use additional parameters to indicate which subset of the array is currently active.
For example, if you occasionally require a 3-element array and at other times a 5-element array, you should define the parameter as a 5-element array. Then, use additional parameters to indicate the current number of elements being utilized.
Regards,
Shivam.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by