Clear Filters
Clear Filters

Change parameter dimensions with setparam method

6 views (last 30 days)
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.

Answers (1)

Shivam Lahoti
Shivam Lahoti on 14 Feb 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.




Community Treasure Hunt

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

Start Hunting!