Accessing matlab object properties from Python

78 ビュー (過去 30 日間)
Andres Codas
Andres Codas 2016 年 11 月 29 日
回答済み: Bo Li 2016 年 11 月 30 日
I'm compiling a matlab handle object and instantiating it from Python using the Matlab Compiler Runtime.
I manage to call instance methods as it is done in this example
However, how can I get properties?, i.e., from the example in the link above how do I write in Python "b = tr.Base"


Bo Li
Bo Li 2016 年 11 月 30 日
I can think of following three approaches:
  1. eng.getfield(tr, 'Base'). This getfield function is designed for structure, and it works for class but may not work in the future.
  2. eng.subsref(tr, {'type':'.','subs':'Base'}). This usage is a little tedious but should work in long term.
  3. Add a get method to the class for each property to be accessed by Python.

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by