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 件のコメント

Nikhil Sapre
Nikhil Sapre 2021 年 6 月 29 日
Hi Ehsan,
What version of MATLAB are you using?
Can you post snippet of your code that is running into errors?
Ehsan Akhavast
Ehsan Akhavast 2021 年 6 月 29 日
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
Nikhil Sapre
Nikhil Sapre 2021 年 7 月 1 日
And how are you calling this function?
Ehsan Akhavast
Ehsan Akhavast 2021 年 7 月 2 日
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

サインインしてコメントする。

回答 (0 件)

タグ

質問済み:

2021 年 6 月 29 日

コメント済み:

2021 年 7 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by