matlabからpy​thonコードの可変​長キーワード引数にデ​ータを渡す方法

3 vues (au cours des 30 derniers jours)
Yusuke Sakamaki
Yusuke Sakamaki le 1 Août 2022
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)

Réponses (0)

Catégories

En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by