I want to go through the code to find out where variables are used in the model and what functions are available.

조회 수: 15 (최근 30일)
I want to go through the code to find out where variables are used in the model and what functions are available. Equivalent to the following operation is implemented using code.

채택된 답변

Fangping
Fangping 2024년 7월 15일
Thanks for your help, I have found the answer to this question.
varObj = Simulink.VariableUsage(needcheckvar,'base workspace');
varsToImport = Simulink.findVars('MyModel',varObj,'FindUsedVars','on');
varsToImport.Users
You can see which modules are used.
Note: "needcheckvar" can be char or cell.

추가 답변 (2개)

Dheeraj
Dheeraj 2024년 6월 26일
Hi Fangping,
I understand you want to programmatically find where variables are used in a Simulink model.
This can be acheived using MATLAB's "find_system" function. This function allows you to search for models, blocks, lines, ports, and annotations directly from MATLAB scripts.
To know more about how to use "find_system" and the functional parameters that can be passed, you could refer to the below MATLAB's documentation.
  댓글 수: 1
Fangping
Fangping 2024년 6월 27일
Hello, I want to find out which modules of variables are used in the model, but the location of model attributes used by each module is not the same. Unless I know all of the attribute fillable variable names in advance, I can't find all the modules that use variables.

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


Matlab Pro
Matlab Pro 2024년 6월 26일
Well - maybe this is obvious ...:
"where variables are used"
type Ctrl-Shift-F which opens the "Find in files" GUI.
I have attached an image with the GUI and marked places you need to change/configure according to your needs
" what functions are available"
If you can open the file in Matlab editor - all you need to do is click on the "GoTo" button (see another attached image)
Good luck
  댓글 수: 1
Fangping
Fangping 2024년 6월 27일
There is no code that can be implemented, I want to replace the GUI operation by code, because the number I am looking for is relatively large.

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

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by