How can I pass the following visa TCPIP constructor by IP address variable.
조회 수: 1 (최근 30일)
이전 댓글 표시
The expression:
PS1_obj = visa('NI','TCPIP0::192.168.200.50::inst0::INSTR')...it works as a literal expression but when I try to pass in a variable for the IP address the visa constructor errors.
Example:
ipaddr = '192.168.200.50'
PS1_obj = visa('NI','TCPIP0::%s::inst0::INSTR',ipaddr)...with variable declaration for the IP address.
Error using visa (line 293)
Invalid property: '192.168.200.50' specified.
댓글 수: 0
답변 (2개)
Walter Roberson
2019년 1월 19일
Use sprintf to construct the character vector. The visa() function itself has no provision for substitution of strings.
댓글 수: 1
Walter Roberson
2019년 1월 21일
PS1_obj = visa('NI', sprintf('TCPIP0::%s::inst0::INSTR',ipaddr) )
참고 항목
카테고리
Help Center 및 File Exchange에서 Instrument Control Toolbox Supported Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!