Borrar filtros
Borrar filtros

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 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 9 de Dic. de 2023
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).

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by