Contenido principal

Edición programática de modelos

Utilice API para realizar tareas básicas de modelado, como añadir, configurar y conectar bloques

Puede crear, editar, buscar y comprobar modelos de Simulink® de manera programática. Para interactuar con un modelo de manera programática, el modelo debe estar cargado. Crear o abrir un modelo también carga el modelo. Utilice las funciones enumeradas en Crear modelos para crear, cargar o abrir un modelo. Después, utilice el resto de las funciones de esta página para editar el modelo y su contenido de manera programática. En los argumentos de entrada de las funciones, especifique el objeto que desea que la función edite como un identificador, ruta o nombre de archivo. Este objetivo puede ser un modelo, un componente como un subsistema o biblioteca, o un elemento de modelo, como un bloque o línea de conexión. Puede especificar objetivos cuyos nombres y ubicaciones conozca o puede buscar objetivos que cumplan determinados criterios de manera programática. Para obtener más información, consulte la documentación de la función y Get Handles and Paths.

Cuando desee compartir un modelo con terceros sin revelar la propiedad intelectual, cree una versión protegida del modelo utilizando la función Simulink.ModelReference.protect (Embedded Coder). Para obtener más información, consulte Protect Models to Conceal Contents (Embedded Coder).

Para obtener información sobre cómo ejecutar simulaciones de manera programática, consulte Ejecutar simulaciones de forma programática. Para crear y editar proyectos de manera programática, consulte Create and Edit Projects Programmatically. Para configurar el editor de Simulink de manera programática, consulte Programmatic Model Editor Appearance Parameters. Para depurar simulaciones desde la ventana de comandos de MATLAB®, consulte Depurar simulaciones de forma programática.

Funciones

expandir todo

getSimulinkBlockHandleGet block handle from block path
getfullnameGet path that identifies block or line
get_paramObtener nombres y valores de parámetros
gcsGet path name of current system
gcbGet path name of current block
gcbhObtener el identificador del bloque actual
gcbpGet Simulink.BlockPath object for current block
bdrootTop-level model of current system
getCurrentAnnotationGet current annotation object
getCallbackAnnotationGet annotation executing callback

Encontrar elementos de un modelo

find_systemFind models, blocks, lines, ports, and annotations
Simulink.findBlocksBuscar bloques en modelos de Simulink
Simulink.findBlocksOfTypeEncontrar un tipo específico de bloque en modelos de Simulink
Simulink.FindOptionsSpecify options for finding blocks in models and subsystems
hilite_systemHighlight block, signal line, port, or annotation

Encontrar modelos

find_systemFind models, blocks, lines, ports, and annotations
Simulink.allBlockDiagramsFind loaded Simulink models and libraries
modelfinderSearch and open examples, models, and projects (Desde R2022a)
modelfinder.importDatabaseImport database to Model Finder (Desde R2023b)
modelfinder.createDatabaseCreate new database to index models (Desde R2023b)
modelfinder.setDefaultDatabaseSet default database to index models (Desde R2023b)
modelfinder.setSearchDatabaseSet search scope to find models (Desde R2023b)
modelfinder.searchFilterCreate Model Finder search filter (Desde R2025a)
modelfinder.registerFolderIndex models in Model Finder (Desde R2022a)
modelfinder.unregisterFolderRemove models from Model Finder (Desde R2022a)
modelfinder.deleteDatabaseRemove database from Model Finder (Desde R2023b)

Obtener metadatos de modelos

Simulink.MDLInfoExtract SLX, SLXP, or MDL file information without loading file
Simulink.MDLInfo.getDescriptionExtract SLX, SLXP, or MDL file description without loading file
Simulink.MDLInfo.getMetadataExtract SLX, SLXP, or MDL file metadata without loading file

Iniciar Simulink

simulinkAbrir la página de inicio de Simulink
start_simulinkIniciar Simulink sin abrir ninguna ventana
isSimulinkStartedCheck whether Simulink is started
slLibraryBrowserOpen, load, and close Simulink Library Browser, create and get handle of Library Browser object

Crear, cargar, abrir, guardar y cerrar modelos

new_systemCreate Simulink model or library in memory
load_systemCargar un modelo de Simulink en la memoria
open_systemOpen model, library, subsystem, or block dialog box
save_systemSave Simulink model
close_systemClose Simulink model window or block dialog box
bdcloseClose any or all Simulink model windows unconditionally

Añadir, reemplazar y eliminar bloques

add_blockAñadir un bloque a un modelo
addtermsAdd terminators to unconnected ports in model
replace_blockReplace blocks in Simulink model
delete_blockDelete blocks from Simulink system
Simulink.BlockDiagram.deleteContentsDelete graphical contents of model
Simulink.SubSystem.deleteContentsDelete contents of subsystem

Conectar bloques

Simulink.connectBlocksConnect blocks with signal lines (Desde R2024b)
add_lineAdd line to Simulink model
delete_lineDelete line from Simulink model

Editar parámetros

get_paramObtener nombres y valores de parámetros
set_paramEstablece el valor del parámetro de Simulink
add_paramAdd parameter to Simulink model
delete_paramDelete model parameter added with add_param function
docblockGet or set editor invoked by Simulink DocBlock block

Configurar el diseño de un modelo

Simulink.BlockDiagram.arrangeSystemImprove layout of block diagram
Simulink.BlockDiagram.routeLineRoute existing lines of model
Simulink.BlockDiagram.resizeBlocksToFitContentAdjust block size to fit displayed value (Desde R2024b)

Agrupar elementos de un modelo en subsistemas

Simulink.BlockDiagram.createSubsystemCreate subsystem containing specified set of blocks
Simulink.BlockDiagram.expandSubsystemReplace subsystem with subsystem contents
Simulink.SubSystem.copyContentsToBlockDiagramCopy graphical contents from subsystem to another model
Simulink.SubSystem.deleteContentsDelete contents of subsystem
bdIsSubsystemDetermine whether model is subsystem
isSimulinkStartedCheck whether Simulink is started
bdIsLoadedDetermine whether model, subsystem, or library is loaded
bdIsDirtyDetermine whether model, subsystem, or library has unsaved changes
slIsFileChangedOnDiskDetermine whether model has changed since it was loaded
bdIsLibraryDetermine whether model is library
bdIsSubsystemDetermine whether model is subsystem
edittime.getDisplayIssuesCheck whether model design warnings and errors are on
edittime.setDisplayIssuesDetect model design errors and warnings

Utilizar plantillas de modelos

Simulink.exportToTemplateCreate template from model or project
Simulink.createFromTemplateCreate model or project from template
Simulink.findTemplatesFind model or project templates with specified properties
Simulink.defaultModelTemplateSet or get default model template

Exportar modelos

Simulink.ModelReference.protectObscure referenced model contents to hide intellectual property
Simulink.exportToVersionExport model, library, or project for use in previous version of Simulink
Simulink.exportToTemplateCreate template from model or project
slCharacterEncodingSpecify encoding to use in code generated from Simulink models

Imprimir modelos

frameeditOpen PrintFrame Editor to edit print frames for Simulink and Stateflow block diagrams
orientPaper orientation for printing or saving
printPrint figure or save to specific file format

Objetos

ModelFinderFilterFiltro de búsqueda de Model Finder (Desde R2025a)
Simulink.AnnotationCrear y especificar propiedades de anotaciones de texto, imagen y área

Temas

Especificar objetos para editar de manera programática

Crear modelos

Dar formato a los modelos

Compartir modelos