Defining direct transfer paths without compilation / execution

I am currently working on a tool written in M-Script that performs a set of checks on this simulink model. This tool does not compile / does not execute the model, I use find_systemit get_paramto get all the necessary information to run the routines of my tool.

I have reached the point where I need to determine if a particular block has a direct channel or not. I'm not quite sure how to do this. Two possible solutions come to mind:

  • The property can store this information and can be accessed via get_param. Having studied this, I could not find such property.
  • Some types of blocks have a direct path (Sum, Logic, ...), others do not (Unit Delay, Integrator), so I can use the type of block to determine if the block has a direct channel or not. Since I am not an experienced Simulink model, I am not sure if it is possible to find out if a block has a direct channel just by looking at its block type. In addition, this will require a lookup table that includes all types of Simulink blocks. An impossible task, as additional types of blocks can be added to Simulink through third-party modules.

Any help or pointers to possible solutions are welcome.

+4
source share
3 answers

after some further research ...

There is a “formal solution” to Matlab:

m

, ;)


:

, . , , . :

  • Constant Terminator
  • , .
  • add_line s
  • , xout .
  • , , .
  • , try/catch

, , . , , .


, script :

function feedthrough = hasfeedthrough( input )

% get block path
blockinfo = find_system('simulink','Name',input);
blockpath = blockinfo{1};

% create new system
new_system('feed');
open_system('feed');

% add test model elements
src = add_block('simulink/Sources/Constant','feed/Constant');
src_ports = get_param(src,'PortHandles');
src_out = src_ports.Outport;
dest = add_block('simulink/Sinks/To Workspace','feed/simout');
dest_ports = get_param(dest,'PortHandles');
dest_in = dest_ports.Inport;
test = add_block(blockpath,'feed/test');
test_ports = get_param(test,'PortHandles');
test_in = test_ports.Inport;
test_out = test_ports.Outport;
add_line('feed',src_out,test_in);
add_line('feed',test_out,dest_in);

% setup simulation
set_param('feed','StopTime','0.1');
set_param('feed','Solver','ode3');
set_param('feed','FixedStep','0.05');
set_param('feed','SaveState','on');

% run simulation and get states
sim('feed');

% if condition for blocks like state space
feedthrough = isempty(xout);
if ~feedthrough
    a = simout.data;
    if ~any(a == xout);
        feedthrough = ~feedthrough;
    end
end

delete system
close_system('feed',1)
delete('feed');

end

, , 'Gain', 1, 'Integrator', 0.

- 1.3 , .

, , , :

  • , , , .
  • "" , , . , , , 1, .

, , .


- StateSpace, AND. "" . , , .

: xout yout, : , . , . , , .

simout :

% if condition for blocks like state space
feedthrough = isempty(xout);
if ~feedthrough
    a = simout.data;
    if ~any(a == xout);
        feedthrough = ~feedthrough;
    end
end
+5

:

, :

  • . .
  • "" . .
  • Scroll "" , , .

, ...

+1

@thewaywewalk, , , ,

enter image description here

( , State-Space , .)

, ,

enter image description here

>> modelname([],[],[],'compile');

( , , ), . , , , .

>> modelname([],[],[],'term');

inports outprts, .

+1

All Articles