How to fix the problem of fetching the simulink block from the customized library in the matlab app designer using matlab app designer code?

5 ビュー (過去 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.
add_block('simulink/Commonly Used Blocks/Constant','myModel/Constant');
But, on applying the same code to select the simulink block from our customized library, it shows the following error.
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.

回答 (1 件)

Fangjun Jiang
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).


Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索




Community Treasure Hunt

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

Start Hunting!

Translated by