필터 지우기
필터 지우기

Python language in Matlab "No appropriate method, property, or field"

조회 수: 10 (최근 30일)
Davide
Davide 2016년 3월 1일
댓글: Davide 2016년 3월 2일
In the Python Shell the following command (used to pilot the Digsilent Powerfactory software) works fine: app.GetFromStudyCase("ComLdf"). However, I am not able to identify a suitable translation for this command within the Matlab environment. For example, using the syntax app.GetFromStudyCase('ComLdf'), Matlab gives the following error: "No appropriate method, property, or field 'GetFromStudyCase' for class 'py.powerfactory.Application'."
Any suggestion?
Thank you in advance for your support.

채택된 답변

Robert Snoeberger
Robert Snoeberger 2016년 3월 2일
What type of attribute is 'GetFromStudyCase'? Is it an instance method, static method, etc? One way to check is to look at the display. What does the following command display?
>> py.getattr(app, 'GetFromStudyCase')
Here are a few workarounds to try:
1. Use eval to call the method.
py.eval('app.GetFromStudyCase("ComLdf")', struct('app', app))
2. Use feval to invoke the instance method object.
methodObj = py.getattr(app, 'GetFromStudyCase');
feval(methodObj, 'ComLdf') % starting in R2015a, the syntax methodObj('ComLdf') should work
3. Use py.operator.methodcaller to call the method.
f = py.operator.methodcaller('GetFromStudyCase', 'ComLdf');
feval(f, app) % starting in R2015a, the syntax f(app) should work
  댓글 수: 1
Davide
Davide 2016년 3월 2일
Actually, all the three methods work fine.
The getattr command displays:
Python Method with no properties.
"<powerfactory.Method 'GetFromStudyCase' of PowerFactory>"
Are the three methods you suggested equivalent to call this method?
Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by