- Add the object to the MATLAB engine workspace.
- Call the MATLAB “eval” function to execute the required statement (‘rl_channel(input)’ in this case) in MATLAB.
Call MATLAB RayleighFading in python
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello,
I'm trying to use comm.RayleighFading object from MATLAB in python. After initiating the object, I called that object taking the argument being my input data. However, it returned an error: TypeError: 'matlab.object' object is not callable
How to use this object in python properly? I appreciate the help!
eng = matlab.engine.start_matlab()
rl_channel = eng.comm.RayleighChannel()
y = rl_channel(input)
댓글 수: 0
답변 (1개)
Narvik
2023년 9월 13일
Hi,
I understand that you are facing an issue while trying to use a MATLAB object in Python. The error “TypeError: 'matlab.object' object is not callable” occurs when you try to call, with ‘()’, an object that is not callable.
To use a MATLAB object properly in Python:
Please find the example code below:
import matlab.engine
eng = matlab.engine.start_matlab()
rl_channel = eng.comm.RayleighChannel()
% add object to MATLAB engine workspace.
eng.workspace['rl_channel'] = rl_channel
% call rl_channel with your input using eval function.
y = eng.eval('rl_channel(input)')
For more information on using the MATLAB workspace in Python and “eval” function, refer to the following documentation links:
https://www.mathworks.com/help/matlab/matlab_external/use-the-matlab-engine-workspace-in-python.html
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Call MATLAB from Python에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!