How to use handles/pathnames with "delete_line" function?

6 vues (au cours des 30 derniers jours)
Burak Bayram
Burak Bayram le 20 Oct 2017
I have block handles and pathnames but delete_line function always gives the error of : "Invalid Simulink object handle". I mean I get handles and pathnames with "get_param" function so there should be no way of being them invalid.
I may be doing mistakes with using dots, paranthesis and brackets but matlab should give that error first, anyways here are my codes;
BlockHandle = get_param('DL/Subsystem/Subsystem', 'Handle');
Port = get_param('DL/Subsystem/Mux', 'PortConnectivity'); % Subsystem block connected to Mux block, from its input to Mux's output.
SourceHandle = get_param(Port(1,1).SrcBlock, 'Handle') % Source is the block which connected to inport of Mux block.(Subsystem Block.) SourceHandle and BlockHandle is the same as they should be.
delete_line = ('DL', 'Subsystem/1' , 'Mux/1') % This deletes the line, but It doesn't delete the line in the subsystem "subsystem",
%I work on a large file, so there may be so much more of this, I want to use handle or pathname because of this.
delete_line = ('DL', (SourceHandle)/1, 'Mux/1 % Error : Invalid Simulink obejct handle.
%then tried this thought maybe If I can have the handle with port number there shouldn't be any error;
k = get_param(SourceHandle, 'Ports')
PortHandle = get_param(k(1), 'Handle') % Also Error : Invalid Simulink object handle.
I could'nt figure out how to do this. "Name/PortNumber" works but I have the same name repeatedly.. So I need to use handle or pathname, I tried pathname it is not happening neither.
I think there might be a mistake I do with brackets or dots while using delete_line.

Réponses (1)

Burak Bayram
Burak Bayram le 20 Oct 2017
Alternative Salvation for this problem;
using LineHandle, i.e.;
MuxLines = get_param(allMuxes{1}, 'LineHandles');
%
InportLineHandle = MuxLines.Inport;
%
OutportLineHandle = MuxLines.Outport;
%
delete_line(InportLineHandle) && delete_line(OutportLineHandle) %deletes all the lines before and after the "Mux".
But this is not the particular answer, I still appreciate the exact answer.

Catégories

En savoir plus sur Author Block Masks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by