Effacer les filtres
Effacer les filtres

How do I change the parameters of a MATLAB Function Block during simulation?

2 vues (au cours des 30 derniers jours)
Aswin Krishna M
Aswin Krishna M le 6 Sep 2021
I have a matlab function block (lets call it block.m) and it has 1 input and 2 parameters attached to it. The parameters to the block are loaded from the base workspace. I want to change the parameter values at each simulation. How do I do it?

Réponses (1)

Pavan Sahith
Pavan Sahith le 12 Oct 2023
Hi Aswin,
I understand you have a MATLAB Function block with 1 input and 2 parameters, and you want to change the parameter values at the start of each simulation.
If they are being fetched from the base workspace at start of each simulation, you can change their values using the ‘InitFcn’ callback in the Model Properties under the Model Settings which can be found under the MODELING tab in Simulink.
To ensure that your parameters are being loaded from the base workspace, you can utilize 'Model Explorer' to determine the workspace in which they are located and refer to the 'Symbols Pane' to confirm their type as 'Parameter Data' , by looking under the same MODELING tab.
If you want to change the value of parameters inside the MATLAB function, the variable in the base workspace do not get updated.
You can also refer to this similar MATLAB answers question for more understanding-https://in.mathworks.com/matlabcentral/answers/776747


En savoir plus sur Simulink Functions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by