SubSystem block does not have a parameter named 'MATLABFunction'

19 visualizaciones (últimos 30 días)
Ajinkys
Ajinkys el 21 de Jul. de 2025
Respondida: Paul el 22 de Jul. de 2025
% Create a new Simulink model
modelName = 'mySimulinkModel';
new_system(modelName);
open_system(modelName);
% Add a MATLAB Function block to the model
blockPath = [modelName, '/MyMATLABFunction'];
add_block('simulink/User-Defined Functions/MATLAB Function', blockPath);
% Set the function code in the MATLAB Function block
functionCode = sprintf('function y = fcn(u)\n y = u^2;\nend');
set_param(blockPath, 'MATLABFunction', functionCode);
% Optionally, set block position
set_param(blockPath, 'Position', [100, 100, 200, 150]);
% Save and close the model
save_system(modelName);
close_system(modelName);

Respuestas (1)

Paul
Paul el 22 de Jul. de 2025
The function code in the Matlab Function block can be modified programatically using MATLABFunctionConfiguration

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by