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

13 vues (au cours des 30 derniers jours)
MathWorks Support Team
MathWorks Support Team le 30 Août 2018
DELETE コマンドでブロックを消去することができますが、そのブロックに接続された線が残ってしまいます。これも含めて消去する方法を教えてください。

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 30 Août 2018
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')

Plus de réponses (0)

Catégories

En savoir plus sur 関数 dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!