How can I use constant parameters from matlab workspace in the Matlab function block in simulink?

34 visualizaciones (últimos 30 días)
I have a long list of constant parameters in my Matlab workspace that my Simulink simulation uses.
I am now trying to use the Matlab Function Block in Simulink, but it can't use the parameters from the workspace?
How do I make the parameters in the Matlab workspace available for the Matlab function block in Simulink?
  2 comentarios
Ankit
Ankit el 2 de Oct. de 2020
how you reading values from workspace? could you explain with an example?
VBBV
VBBV el 2 de Oct. de 2020
Use
% if true
% code
% end
load('workspace.mat')
or if you saved workspace variables to a filename then
%if true
% code
% end
load('filename.mat')
Inside the matlab function

Iniciar sesión para comentar.

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 2 de Oct. de 2020
You need to define a parameter in the MATLAB function block to directly access the data from the base workspace. This show how it can be done: https://www.mathworks.com/help/simulink/ug/parameter-arguments-in-matlab-function-block-functions.html

Más respuestas (0)

Categorías

Más información sobre Simulink Functions 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