Writing Java code in Matlab?

Posted by scooziexp on Stack Overflow See other posts from Stack Overflow or by scooziexp
Published on 2010-04-20T13:51:07Z Indexed on 2010/04/20 13:53 UTC
Read the original article Hit count: 242

Hi,

I'm trying to use the Java commands pw.println() and br.readLine() in Matlab because I have set up a socket (input_socket2) between Matlab and a command-line program I want to control using Java classes BufferedReader and PrintWriter. Before the following snippet of code, I implemented another socket that goes between 2 computers. This works great and I also know that the following snippet of code successfully opens up a communication line between Matlab and the other program. However, Matlab throws an error at pw.println('noop'). I think it has something to do with syntax, but I'm not sure how to write the command in Matlab syntax then:

try
    input_socket2 = Socket(host2,port2);
    input_stream2   = input_socket2.getInputStream;
    d_input_stream2 = DataInputStream(input_stream2);
    br = BufferedReader(InputStreamReader(input_stream2));
    pw = PrintWriter(input_socket2.getOutputStream,true);
    pw.println('noop')
    br.read
end

Any ideas?

© Stack Overflow or respective owner

Related posts about matlab

Related posts about java