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

3 次查看(过去 30 天)
Yusuke Sakamaki
Yusuke Sakamaki 2022-8-1
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 个)

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by