How to fix the problem of fetching the simulink block from the customized library in the matlab app designer using matlab app designer code?
2 ビュー (過去 30 日間)
古いコメントを表示
Here, we are running all the codes shown below in the matlab app designer.
Initialy, we have taken a simulink block from the existing matlab library using this code, and it run successfully.
open_system(new_system('myModel'));
add_block('simulink/Commonly Used Blocks/Constant','myModel/Constant');
set_param('myModel/Constant','position',[140,80,180,120]);
But, on applying the same code to select the simulink block from our customized library, it shows the following error.
open_system(new_system('myModel'));
add_block('simulink/mylib/Constant','myModel/Constant');
set_param('myModel/Constant','position',[220,80,260,120]);
So, the command window in matlab shows following error message.
Error using app2/MylibraryButtonPushed
There is no block named 'simulink/mylib/Constant'
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ... - Show complete stack trace
Error while evaluating Button PrivateButtonPushedFcn.
0 件のコメント
回答 (1 件)
Fangjun Jiang
2023 年 12 月 9 日
It is because your customized library is not set up as "simulink/mylib". It is unlikely you can add your library to underneath "simulink".
Anyway, open your customized library manually, select a block, go to MATLAB Command Window, run "gcb", you will get the fullpath of that block. Use that fullpath as the SourceBlock in add_block(SourceBlock, destination).
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Simulink Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!