How can I execute the same program on MATLAB?
    3 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    horizon
 il 1 Mag 2019
  
    
    
    
    
    Risposto: Walter Roberson
      
      
 il 4 Mag 2019
            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 Commenti
Risposta accettata
  Walter Roberson
      
      
 il 4 Mag 2019
        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 Commenti
Più risposte (1)
  Dvir Haberman
      
 il 1 Mag 2019
        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.
Vedere anche
Categorie
				Scopri di più su Call Python from MATLAB in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


