How to use 'jar' in matlab m file?
3 次查看(过去 30 天)
显示 更早的评论
I have the 'jar' file and the usage of (the classes contained in jar) in java code is like the following:
[code java] import kr.hyosang.coordinate.*;
........
CoordPoint pt = new CoordPoint(126.97553009053178, 37.56456569639763);
CoordPoint ktmPt = TransCoord.getTransCoord(pt, TransCoord.COORD_TYPE_WGS84, TransCoord.COORD_TYPE_KTM);
[/code]
------------------------------------------------------------------
And this is my matlab code which has a problem to run.
clc; clear all;
javaaddpath('TransCoord.jar')
import kr.hyosang.coordinate.*;
CP=CoordPoint
methods(CP)
pt=CP(126.97553009053178, 37.56456569639763)
clear import
clear java
-----------------------------------------------------
I know nothing whatever about JAVA. But the only ting I want to do is
CoordPoint pt = new CoordPoint(126.97553009053178, 37.56456569639763);
CoordPoint ktmPt = TransCoord.getTransCoord(pt, TransCoord.COORD_TYPE_WGS84, TransCoord.COORD_TYPE_KTM);
to run these two lines in my matlab code.
0 个评论
回答(1 个)
Titus Edelhofer
2016-7-25
Hi,
this should work right away:
pt = CoordPoint(126.97553009053178, 37.56456569639763);
ktmPt = TransCoord.getTransCoord(pt, TransCoord.COORD_TYPE_WGS84, TransCoord.COORD_TYPE_KTM);
or let us know what the error message is :).
Titus
5 个评论
Titus Edelhofer
2016-7-27
As Malcolm said, with methods(ktmPt) you should get a list of methods. I could imagine there are methods called getX and getY or something similar. In this case simply do
x = ktmPt.getX();
Titus
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call Java from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!