Identify a connecting line

Hi,
I have a model with several blocks and lines connecting them. I am able to get all my line names using the following:
LineNames= get_param(find_system(gcs,'FindAll','on','type','line'),'Name')
If I tell Matlab the names of two blocks, ie. InputPort and Filter1, does anyone know how I can identify which line in LineNames is conencting these two blocks? Would I have to use 'PortConnectivity'?

답변 (1개)

Babak
Babak 2013년 2월 25일

0 개 추천

here are some useful command you can (may want to) use :
BlocksYoureLookingFor = find_system(gcs,'BlockDialogParams','MyDlgParams')
% or use it with another switch to find your filter block, like
% BlocksYoureLookingFor = find_system(gcs,'BlockType',....)
% now get the line handles of that block,
YourBlocksLineHandles = get_param(BlocksYoureLookingFor(1),'LineHandles')
% note that there may be more than 1 block found.
% here's how you can find the name of the inport line of the block:
Line_name = get(YourBlocksLineHandles.Inport,'Name')
% here's how you can change the name of the inport
set(YourBlocksLineHandles.Inport,'Name','YourFavouriteName')

댓글 수: 4

mtr
mtr 2013년 2월 25일
Hi Babak,
Thanks for the suggestions. When I use the Line_name command, I get an error saying "Attempt to reference field of non-structure array". My "YourBlocksLineHandles" returns a [1x1 struct]
BlocksYoureLookingFor = find_system(gcs,'Name','Filter')
YourBlocksLineHandles = get_param(BlocksYoureLookingFor,'LineHandles')
Line_name = get(YourBlocksLineHandles.Inport,'Name')
I don't get which line you get the error. There are 3 lines on what your last comment says: find_system, get_param, get. Please clarify which line you are getting the error.
You can always type these in MATLAB's command window and check what the result of the structure/variable is. You can always say
class(YourBlocksLineHandles)
to check its class. You can also check the fields of this structure if necessary.
mtr
mtr 2013년 2월 26일
I get the error on the last line: Line_name = get(YourBlocksLineHandles.Inport,'Name')
Please run these lines in MATLAB's command window, Try to see what
YourBlocksLineHandles
is. It should be a structure. You can check it's fields by typing this in command window:
fieldnames(YourBlocksLineHandles)
Check see if Inport is one of the options or not.

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

카테고리

도움말 센터File Exchange에서 Model, Block, and Port Callbacks에 대해 자세히 알아보기

질문:

mtr
2013년 2월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by