matlabからpythonコードの可変長キーワード引数にデータを渡す方法
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
matlabからpythonコードの可変長のキーワード引数にデータを渡すにはどのようにしたらよいでしょうか?
pyargsオブジェクトで代入することでpythonコード実行できることがわかりましたが、
matlab構造体からpyargsオブジェクトに変換する方法が分からない状態です。
【実行環境】
・Windows 10
・MATLAB R2021a
・Python 3.8.10
【pythonコード】output_class.py
import json
class output:
def __init__(self):
pass
def run(self,**kwargs):
jsf = open('./out.json',mode='w')
json.dump(kwargs,jsf)
jsf.close()
【matlabコード】test_kwargs.m
st = struct('real',1.0 ,'imag' ,2.0)
pyd = py.dict(st)
pyarg = ???(pyd) % Python dictオブジェクトをpyargsに変換方法が分からない
obj = py.output_class.output()
obj.run(pyarg)
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!