ブロック消去後のライ​ンをまとめて消去する​ことはできますか?

13 次查看(过去 30 天)
MathWorks Support Team
DELETE コマンドでブロックを消去することができますが、そのブロックに接続された線が残ってしまいます。これも含めて消去する方法を教えてください。

采纳的回答

MathWorks Support Team
MATLAB/Simulink の標準関数にはこのような機能はありませんが、プログラミングにより実現することができますので、その方法をご紹介いたします。
■サンプルプログラム
(以下の2つの関数は両方とも sampleprog.m ファイルに保存します)
function sampleprog(sys)
% システム中の全ラインのハンドルを取得
lines = find_system( sys, ...
'LookUnderMasks', 'all', ...
'FindAll', 'on', ...
'Type', 'line' ) ;
% それぞれのラインで、ハンドルが存在する場合に削除関数を使用
for i=1:length( lines )
if ishandle( lines( i ) )
delete_unconnected( lines( i ) )
end
end
%削除関数の例
function delete_unconnected( line )
%'SrcPortHandle'がマイナスの場合、残ったラインと判断できる
if get( line, 'SrcPortHandle' ) < 0
delete_line( line ) ;
return
end
LineChildren = get( line, 'LineChildren' ) ;
%'DstPortHandle'がマイナスの場合、残ったラインと判断できる
if isempty( LineChildren )
if get( line, 'DstPortHandle' ) < 0
delete_line( line ) ;
end
else
for i=1:length( LineChildren )
delete_unconnected( LineChildren( i ) )
end
end
■実行手順
1) モデルを開く
>> f14
2) 適当なブロックを削除して、ラインを残す
3)以下で残ったラインを削除できます。
>> sampleprog('f14')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 関数 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!