How can I execute the same program on MATLAB?
조회 수: 2 (최근 30일)
이전 댓글 표시
I would like to execute the following procedure on MATLAB.
This program is written on Python and succeeded to execute, but I'm troubled with writing it on MATLAB.
Python3.6
# -*- coding: utf-8 -*-
import time
import sys
for i in range(10):
if i == 9:
print("end")
sys.exit()
print("Hello")
time.sleep(1)
댓글 수: 0
채택된 답변
Walter Roberson
2019년 5월 4일
for i = (1:10)-1
if i == 9
fprintf("end\n");
exit();
end
fprintf("Hello\n");
pause(1);
end
Note that sys.exit in python means to exit python, so the equivalent program quits all of MATLAB.
댓글 수: 0
추가 답변 (1개)
Dvir Haberman
2019년 5월 1일
Hi,
Basically, whether if it's linux of windows, you should be able to make it run just by specifying the location of the script with:
system('commandstr')
Hope this was helpful.
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!