How to do "class " like Python to control equipment

조회 수: 5 (최근 30일)
Pochun Liao
Pochun Liao 2023년 4월 27일
댓글: Steven Lord 2023년 4월 27일
Hi,
Could I get an example to show how could I do the same thing in maltlab as Python.
how could I set up class with variable and functions?
set functions under the class and recall?
Below is the python code, could you provide me an example how could I do that in Matlab ?
I read the class exmplae and stil don't know how to set the perporty with variabel, thanks
class SMU200A(Generic_VISA.Generic_VISA):
def __init__(self,GPIB_Address,GPIB_Controller = 0, TCPIP_Address = '127.0.0.1', hw = 1, Route = "A"):
"""
Initialize and most importantly, choose the default baseband and RF route
"""
Generic_VISA.Generic_VISA.__init__(self,GPIB_Address,GPIB_Controller = 0, TCPIP_Address = TCPIP_Address)
# self.reset()
self.hw = hw
self.Route = Route
self.Set_Route()
def Set_Route(self, hw = None, Route = None):
if hw == None:
hw = self.hw
if Route == None:
Route = self.Route
self.write(":SOURce{}:BB:ROUTe {}".format(hw, Route))
def Get_BB_Count(self):
return self.ask(":SOURce:BB:PATH:COUNt?")
if __name__ == "__main__":
SG = SMU200A(GPIB_Address = 28, hw = 1, Route = "A")
SG.reset()
SG.send_wv_file(os.getcwd(), 'pd_out_FRAA_NXP_0_lambda100_iter_3original_rc320.wv')

답변 (1개)

Steven Lord
Steven Lord 2023년 4월 27일
You can create class files in MATLAB. But rather than writing your own VISA interface, if you have a license for Instrument Control Toolbox you may want to use the VISA interface functionality provided in that toolbox.
  댓글 수: 2
Pochun Liao
Pochun Liao 2023년 4월 27일
I could use the control toolbox, but coould you pleae tell me how to create "class" in matlab as in Python.
I could call out control boox and have the "wrte" read, but still want to have a class to get all the functions in it.
Steven Lord
Steven Lord 2023년 4월 27일
See the first documentation page I linked.

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

카테고리

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

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by