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

조회 수: 3 (최근 30일)
Yusuke Sakamaki
Yusuke Sakamaki 2022년 8월 1일
편집: 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