フィルターのクリア

Adding Toggle Switch programmatically

2 ビュー (過去 30 日間)
Osama Al-Najjar
Osama Al-Najjar 2018 年 6 月 23 日
回答済み: Christopher Wallace 2018 年 6 月 27 日
Hello All, I am working on a project where I generate a custom Simulink model using a Matlab script. All being figured, I stumbled upon adding a Toggle switch to a constant block using code only, I don't want to press the switch then select the block's variable name to connect it to the switch, what I want is telling the toggle switch by code to connect to a predefined constant block. I appreciate any help or ideas !

採用された回答

Christopher Wallace
Christopher Wallace 2018 年 6 月 27 日
Hi Osama, If I understand you correctly you could use the following code as an example:
add_block('simulink/Sources/Constant', [gcs, '/Constant1'], 'Position', [0, 0, 30, 30]);
add_block('simulink/Sources/Constant', [gcs, '/Constant2'], 'Position', [0, 45, 30, 75]);
add_block('simulink/Signal Routing/Manual Switch', [gcs, '/Manual Switch'], 'Position', [100, 7, 130, 43]);
add_line(gcs, 'Constant1/1', 'Manual Switch/1');
add_line(gcs, 'Constant2/1', 'Manual Switch/2');
This will result in:
Best Regards,
Chris

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreate Large-Scale Model Components についてさらに検索

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by