How to find a variable in Simulink Model

조회 수: 181 (최근 30일)
nkumar
nkumar 2015년 7월 8일
편집: dc 2023년 6월 3일
I want to know the variable uses in demo sldemo_mdlref_datamngt.mdl.here assume in counter2 ,right click and if u see Model Reference Parameter there are two variables Params, ICs under Model argument values (for this instance).Can I know what it is and what are its values.I read help in Simulink but could not get relevant answer .On what basis these variables arte passed

채택된 답변

Sebastian Castro
Sebastian Castro 2015년 7월 10일
The most general answer to your question is to use the Model Explorer. It's a great tool that lets you navigate through a model hierarchy and look at all the variables defined in different places.
You can also
  1. Search for variables within the Model Explorer.
  2. Right-click a variable in Model Explorer and select "Find where used".
  3. Right-click any Simulink model or block and select "Find referenced variables".
  4. Use the Simulink.findVars function to do search variables programmatically. [Example here]
- Sebastian
  댓글 수: 1
Alexander Guth
Alexander Guth 2019년 5월 7일
Hi,
I know this is kind of an outdated thread, but I have a follow-up question. All of your above points work, however it is a different story if I am looking for a nested variable (in a struct) as also asked by the original author. If I use "Find referenced variables" it just tells me that the generic struct (where I store all of my parameters) is used - which is of no help at all. Also findVars did not work following this approach:
Simulink.findVars('Wind_Turbine','Name','WT_Params.Generator.frequency')
% 0×0 VariableUsage array with properties: (...)
How can I find these usages of these nested variables?

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Omid Saber
Omid Saber 2020년 1월 23일
You can do what Sebastian said to find where the parameters are used. But if you're looking for the valuesor how that parameter is initiated, you should look under the mask. For this, if the mask is linked to a library either got to the library block or break the link to library and work locally on the mask. Right click on the mask and click on Mask>Edit Mask. In the opened window go to the Initilization tabThat's where the parameters are locally defined and you can edit them.

dc
dc 2023년 6월 3일
편집: dc 2023년 6월 3일
wondful answer,to search under reference,i modified like this:
varObj = Simulink.VariableUsage(varNames,'base workspace');
unusedVars = Simulink.findVars(modelname,varObj,...
'FindUsedVars','off','SearchReferencedModels','on');

카테고리

Help CenterFile Exchange에서 Subsystems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by