Converting a Java double[] to a MATLAB vector

1 vue (au cours des 30 derniers jours)
Christopher Dembia
Christopher Dembia le 14 Déc 2017
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();

Réponses (0)

Catégories

En savoir plus sur Call Java from MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by