how to check if an specific name is existed inside a simulink

조회 수: 10 (최근 30일)
wenchao zhang
wenchao zhang 2023년 10월 20일
답변: Walter Roberson 2025년 3월 31일
i want to check if an specific name(parameter,signallines,..) is existed inside a simulink model, if use can find_system work in this case? or any more quick command can be used to meet this requirement.

채택된 답변

atharva
atharva 2023년 11월 10일
Hey Wenchao,
I understand that you are trying to check if a specific name is a parameter or is a variable declared inside a simulink model.
You can use exist function which checks the existence of a variable.
exist name returns the type of name as a number. This list describes the type associated with each value:
  • 0 — name does not exist or cannot be found for other reasons. For example, if name exists in a restricted folder to which MATLAB® does not have access, exist returns 0.
  • 1 — name is a variable in the workspace.
  • 2 — name is a file with extension .m, .mlx, or .mlapp, or name is the name of a file with a non-registered file extension (.mat, .fig, .txt).
  • 3 — name is a MEX-file on your MATLAB search path.
  • 4 — name is a loaded Simulink® model or a Simulink model or library file on your MATLAB search path.
  • 5 — name is a built-in MATLAB function. This does not include classes.
You can find more about the function exist on Mathworks Documentation - https://www.mathworks.com/help/matlab/ref/exist.html
I hope this helps!

추가 답변 (1개)

Walter Roberson
Walter Roberson 2025년 3월 31일
To check whether a particular name exists anywhere in a Simulink model, you need to use find_system() repeatedly. Some of the calls will have to specify FindallAll 'on' along wiith various 'Type' parameters. I do not believe that you can combine multiple 'Type' with the same find_system() command
You might also need to
find_system(model,MatchFilter=@Simulink.match.allVariants)
to check all blocks including variants.

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by