Clear Filters
Clear Filters

writeline function not available

21 views (last 30 days)
Sashi Nepal
Sashi Nepal on 6 Dec 2022
Answered: James Water Bird on 6 Dec 2022
I want to establish tcp/ip connection with the device AMC300 and then send some command. The example code uses the code below to connect to device
IP = '';
% Setup connection to AMC
amc = tcpclient(IP,9090);
amc = connect(IP);
and the code below is used to send the command to device.
data_send = sprintf('{"jsonrpc": "2.0", "method": "com.attocube.amc.control.setControlOutput", "params": [%i, %i], "id": 1, "api": 2}', axis, enable);
writeline(tcp, data_send);
My problem is matlab is complaining that function writeline is not available or defined. I'm using matlab 2020b academic version. How can I make this writeline command available?

Answers (1)

James Water Bird
James Water Bird on 6 Dec 2022
The writeline function is part of the Instrument Control Toolbox, which is a toolbox for MATLAB that allows you to communicate with instruments and devices over a variety of communication interfaces, including TCP/IP. In order to use the writeline function, you need to have the Instrument Control Toolbox installed and licensed on your system.
If you are using the academic version of MATLAB, it is possible that the Instrument Control Toolbox is not included in your license. In that case, you will need to contact your administrator or MathWorks customer support to obtain a license for the toolbox.
Once you have the Instrument Control Toolbox installed and licensed, you can access the writeline function by adding the following line of code at the beginning of your script:
% Add the Instrument Control Toolbox to the path
Replace /path/to/instrument/control/toolbox with the actual path to the Instrument Control Toolbox on your system. This will add the toolbox to the MATLAB search path, allowing you to use the 'writeline' function in your script.
If you are still having trouble using the 'writeline' function, you can also try using the 'fprintf' function


Find more on Instrument Connection and Communication in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!