OOP with Object-creation in Simulink

2 visualizaciones (últimos 30 días)
Steffen
Steffen el 22 de Feb. de 2024
Respondida: Fangjun Jiang el 22 de Feb. de 2024
I would like to use OOP architectures in Simulink/Matlab. For this purpose, I have added a Matlab function 'runMain' in Simulink (see Image 1).
Image 1
In this function 'runMain', a Matlab function is then called (see Image 2)
Image 2
In his function a Sensor object is created, and subsequently, the object method 'calculate' is called (see Image 3).
Image 3
However, I receive the following message: Unable to resolve the name 'sensor.calculate'.
The code for the sensor object looks like (see Image 4):
Image 4
Now, I would like to know if it is even possible to create such objects. Thank you very much.
  2 comentarios
Walter Roberson
Walter Roberson el 22 de Feb. de 2024
As an experiment, try
val = calculate(sensor, x, y);
Steffen
Steffen el 22 de Feb. de 2024
Thank you very much for the tip. It is now working...

Iniciar sesión para comentar.

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 22 de Feb. de 2024
Not "MATLAB Function" block, use MATLAB System block

Más respuestas (0)

Categorías

Más información sobre Interactive Model Editing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by