필터 지우기
필터 지우기

Change parameter dimensions with setparam method

조회 수: 5 (최근 30일)
Enzo Yacometti
Enzo Yacometti 2024년 2월 13일
답변: Shivam Lahoti 2024년 2월 14일
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.

답변 (1개)

Shivam Lahoti
Shivam Lahoti 2024년 2월 14일
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.

카테고리

Help CenterFile Exchange에서 Target Computer Setup에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by