How do I change the parameters of a MATLAB Function Block during simulation?
1 view (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Pavan Sahith
on 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
0 Comments
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!