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!