フィルターのクリア

pass data from Matlab to python3 as bytes or bytearray

17 ビュー (過去 30 日間)
Sean Little
Sean Little 2020 年 1 月 28 日
編集済み: Mohammad Sami 2020 年 1 月 29 日
Matlab has a really nice API for interacting with python. I see how to pass lists, and dicts, etc. But I can't figure out how to create a "bytes" or "bytearray" (python3) data variable in Matlab and pass that variable to a python method that expects a "bytes-like" type. I see that bytes in python passed to Matlab result in an array of uint8s, but the reverse does not appear to be true:
>> py.libscrc.usb16(uint8(8))
Python Error: TypeError: a bytes-like object is required, not 'int'
>> py.libscrc.usb16([uint8(8), uint8(9)])
Python Error: TypeError: argument 1 must be read-only bytes-like object, not array.array
Any hints?
Thanks.
  1 件のコメント
Mohammad Sami
Mohammad Sami 2020 年 1 月 29 日
編集済み: Mohammad Sami 2020 年 1 月 29 日
When passing data to python, Matlab is converting your data into type py.int.
Perhaps you can explicitly define the type py.bytes or py.bytearray in Matlab ?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by