Converting a Java double[] to a MATLAB vector
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
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!