フィルターのクリア

SIMULINK mask parameter extract from MATLAB workspace

1 回表示 (過去 30 日間)
Mustafa Duran
Mustafa Duran 2024 年 4 月 16 日
コメント済み: Pavan Sahith 2024 年 4 月 18 日
This is my Simulink diagram. I want to take that 1/inertia gain value from MATLAB workspace and 1/inertia gain value must be identified as mask parameter. I made it mask parameter but i couldn't make to extract it from MATLAB workspace. How can i do that?
Thanks.

回答 (1 件)

Pavan Sahith
Pavan Sahith 2024 年 4 月 17 日
編集済み: Pavan Sahith 2024 年 4 月 17 日
I see that you are encountering an issue while attempting to add a parameter to the mask of a subsystem, following these steps will help you in using a variable from the MATLAB workspace as a mask parameter in your Simulink model.
Ensure that you have accurately defined the variable in the MATLAB Workspace before proceeding.
Steps to set up the Mask Parameter:
  1. In the Mask Editor (which opens after you select Create Mask), go to the Parameters & Dialog tab.
  2. Click Add parameter and choose the type of parameter that best fits your needs (for example, Edit).
  3. In the Name field, enter a name for your parameter (for example, gainValue).
  4. In the Evaluate field, ensure it's set to "on" to allow MATLAB expressions.
  5. Optionally, you can set the Default value to one_over_inertia(1/inertia) or any MATLAB workspace variable. However, this is evaluated only once when the model is loaded, or the mask parameter is refreshed.
These steps will allow you to successfully set a mask parameter. By double-clicking on the subsystem, you can access and review the parameters and their values.
For further information about the Mask Editor and its capabilities, you can refer to the following MathWorks Documentation
Hope this will help you in getting started.
  2 件のコメント
Mustafa Duran
Mustafa Duran 2024 年 4 月 17 日
Can i write it with code section in mask editor with get parameter and set parameter?
Pavan Sahith
Pavan Sahith 2024 年 4 月 18 日
Yes , you can proceed with the steps outlined previously up to step 4 for adding a parameter, let's say 'InverseInertia' here and leave the 'Value' field unchanged by default..
Within the Mask Editor's 'code' section, I generally utilize the Mask's callback mode, which can be set by selecting 'Switch Callback Mode' from the toolstrip.
For retrieving the value of a mask parameter from the MATLAB base workspace, you can try to employ the 'set_param' and 'get_param' functions in the manner described below.
% Initialization code section
function initialization()
if evalin('base', 'exist(''inertia'', ''var'')')
inertiaValue = evalin('base', 'inertia');
set_param(gcb, 'InverseInertia', num2str(1/inertiaValue));
else
disp('Variable ''inertia'' not found in workspace.');
end
end
% Parameter callback section

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSubsystems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by