OOP with Object-creation in Simulink

조회 수: 2 (최근 30일)
Steffen
Steffen 2024년 2월 22일
답변: Fangjun Jiang 2024년 2월 22일
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
Walter Roberson
Walter Roberson 2024년 2월 22일
As an experiment, try
val = calculate(sensor, x, y);
Steffen
Steffen 2024년 2월 22일
Thank you very much for the tip. It is now working...

댓글을 달려면 로그인하십시오.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2024년 2월 22일
Not "MATLAB Function" block, use MATLAB System block

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by