Clear Filters
Clear Filters

Converting a Java double[] to a MATLAB vector

2 views (last 30 days)
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();

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!