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

3 views (last 30 days)
Yusuke Sakamaki
Yusuke Sakamaki on 1 Aug 2022
Edited: Yusuke Sakamaki on 1 Aug 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)

Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!