MATLABでpythonのクラスの呼び出し
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
tomoki takeuchi
il 28 Giu 2019
Risposto: Kojiro Saito
il 29 Giu 2019
pythonで作成したコードのクラス内の情報を引継ぎ、中のメソッドを行いたいのですが、方法が分かりません。
class Hello():
def hello(self)
print "HelloWorld!"
このように作成し、helloのメソッドを仕様したい場合、MATLAB上にはどのように打ち込めばよいのでしょうか。
またpython上の問題があるのでしょうか。
0 Commenti
Risposta accettata
Kojiro Saito
il 29 Giu 2019
以下のようなPythonファイルをMATLABのカレントディレクトリに置いておき、
helloClass.py
class Hello:
def hello(self):
print "HelloWorld!"
# print('HelloWorld!') # Python 3.x
MATLABから以下のように呼ぶことで使用できます。
myHelloClass = py.importlib.import_module('helloClass');
myHello = myHelloClass.Hello();
myHello.hello()
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su MATLAB の Python ライブラリ 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!