How to use workspace values ​​as parameters in MatlabFunction?

6 visualizaciones (últimos 30 días)
Wu YiDau
Wu YiDau el 21 de Mzo. de 2024
Comentada: Dinesh el 21 de Mzo. de 2024
Hi,
I would like to ask Matlab Function how to call the values ​​in Workspace Matrix.
This is my Workspace Matrix
and this is my Matlab Function
Show This ERR.

Respuestas (1)

Dinesh
Dinesh el 21 de Mzo. de 2024
Hello,
In MATLAB functions, if you would like to use a variable from the workspace rather than the ones passed as function arguments, you can use the "evalin" function with the first argument as 'base'.
Link to the documentation:
Here's a code snippet:
pmsm = evalin('base', 'pmsm');
p1 = 3 * pmsm.pp;
  2 comentarios
Wu YiDau
Wu YiDau el 21 de Mzo. de 2024
Thank you for your reply, but used your suggestion.
Matlab gave me another ERR Report.
Dinesh
Dinesh el 21 de Mzo. de 2024
For code generation, I don't think "evalin" is supported because there is no such concept of a workspace once the code is generated in C. It is expected that the function arguments or any global variables are the ones that are being used within the function.

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by