Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
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?

Antworten (1)

Pavan Sahith
Pavan Sahith am 12 Okt. 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

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by