Converting a Java double[] to a MATLAB vector

조회 수: 1 (최근 30일)
Christopher Dembia
Christopher Dembia 2017년 12월 14일
I have Java code that I use in MATLAB, and I would like to convert between my custom Java Vector class and MATLAB vectors. MATLAB will automatically convert a MATLAB vector into a Java double[], which means that if my Vector class has the following constructor:
public Vector(double[] arr);
then I can write the following in MATLAB:
myJavaVec = Vector([1, 2, 3]);
This is excellent. I'd also like to go from my Java Vector to a MATLAB vector. Currently, I can do this via the following:
matlabVec = cell2mat(cell(myJavaVec.getAsJavaArray()));
I need only create the following function in my Java Vector class:
public double[] getAsJavaVector();
Is there any way to make this code even more concise? Ideally, I could have the following:
matlabVec = myJavaVec.getAsMATLABVector();

답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by