How can I pass the following visa TCPIP constructor by IP address variable.

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.

Answers (2)

Use sprintf to construct the character vector. The visa() function itself has no provision for substitution of strings.
Thanks for the response, I tried that but it didn't work. I didn't spend alot of time on it, so let me double check the string.....

Categories

Find more on Instrument Control Toolbox in Help Center and File Exchange

Products

Release

R2018b

Asked:

on 19 Jan 2019

Commented:

on 21 Jan 2019

Community Treasure Hunt

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

Start Hunting!