Why do I receive an error about java

hi , i have this error
any body can help?
Function 'MATLAB Function9' (#271.286.309), line 9, column 1: "import java.net.Socket" Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
line in commond window : import java.net.Socket
Import statements are currently unsupported. Function 'MATLAB Function9' (#271.309.326), line 10, column 1: "import java.io.*" Launch diagnostic report.
Component: MATLAB Function | Category: Coder error
line:import java.io.*

4 Comments

Hi Ehsan,
What version of MATLAB are you using?
Can you post snippet of your code that is running into errors?
hi dear
thanks for your attention
2021a
yeah
this file is about connecting flightgear to simulink
function wp_dist_m =get_wpdist(host, port)
% [WP_DIST_M]=GET_WPDIST(HOST, PORT)
%
% Read distance WP_DIST of aircraft from current waypoint in
% Flightgear over socket connection (HOST, PORT).
% Run Flightgear on HOST (e.g. '127.0.0.1' = localhost) with
% parameter "--props = PORT".
import java.net.Socket
import java.io.*
fg_socket = Socket(host, port);
out = PrintWriter(fg_socket.getOutputStream(), true);
in = BufferedReader(InputStreamReader(fg_socket.getInputStream()));
% waypoint distance meter
out.println(sprintf('get /autopilot/route-manager/wp/dist\r\n'));
wp_dist_m_str = char(in.readLine());
j = strfind(wp_dist_m_str,'''');
%Conversion from sea miles (nm) to meter
wp_dist_m = str2double(wp_dist_m_str(j(1)+1:j(2)-1)) * 1852;
out.close();
in.close();
fg_socket.close();
end
And how are you calling this function?
i want to connecting matlab to flightgear simulator .
this code is apart of 13 code that was from below link .
https://www.mathworks.com/matlabcentral/fileexchange/25047-flightgear-route-manager

Sign in to comment.

Answers (0)

Tags

Asked:

on 29 Jun 2021

Commented:

on 2 Jul 2021

Community Treasure Hunt

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

Start Hunting!