Python call matlab function 'plot', The figure disappeared in few seconds.
이전 댓글 표시
When I use python call the matlab funtion plot, the figure only exists few seconds, then it colsed automatically. Why does have this phenomenon occur? How could I change or add something? Thank you very much.
AddTset.m
function c = AddTest(a,b)
c = a + b;
figure(1)
plot(a,c,'DisplayName','test');
%pause(30);
end
pyCallMat.py
import matlab.engine
if __name__ == '__main__':
eng = matlab.engine.start_matlab()
a = eng.AddTest(1.0,2.0)
print(a)
b = eng.sqrt(4.)
eng.figure(3.0)
eng.plot(a, b, nargout=0)
print(b)
댓글 수: 4
Mohammad Sami
2020년 3월 24일
I presume this maybe because the variable eng get cleared after your function is finished executing. this might perhaps close the matlab engine.
Tianya Duan
2020년 3월 24일
Tianya Duan
2020년 3월 26일
Villa Xue
2022년 3월 11일
Thank you a lot, It works when use: input("Press Enter to continue...") in python
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 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!