Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 465849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:25:09+00:00 2026-05-12T23:25:09+00:00

I have an array created in MATLAB that contains a number of cell type

  • 0

I have an array created in MATLAB that contains a number of cell type objects which contain arrays of doubles.
It’s basically a <1xn cell> array and each cell is an array of doubles.

What I want to do is to somehow export these so that I can then insert the data into Java as a ragged array of arrays of type int. Any thought on how to best do this?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:25:09+00:00Added an answer on May 12, 2026 at 11:25 pm

    It’s difficult to construct a Java array of primitives in Matlab, because Matlab wants to autobox it back into a Matlab array.

    What you can do is create a Java class to help you, using the method signatures to guide Matlab’s autoboxing. A wrapper layer like this may be faster and more convenient than a round trip through a text export.

    package test;
    
    /**
     * Class to help build Java arrays from Matlab.
     */
    public class JavaArrayBuilder {
        /**
         * Assign an array into a larger ragged array
         * @param array ragged array you're building
         * @param i index into array
         * @param subarray this gets autoboxed to int[] from Matlab
         */
        public static void assignIntArray(Object[] array, int i, int[] subarray) {
            array[i] = subarray;
        }
    }
    

    Then you can call it from Matlab like this.

    function ja = build_int_array
    
    mynums = { 1:2, 1:5, 1:7 };
    % Create a Java array of arrays
    dummy = java.lang.Object();
    ja = java.lang.reflect.Array.newInstance(dummy.getClass(), numel(mynums));
    for i = 1:numel(mynums)
        test.JavaArrayBuilder.assignIntArray(ja, i-1, mynums{i});
    end
    % Now you have a Java ragged array, albeit as Object[] instead of int[][]
    

    Afterwards, you’ll need to convert the Object[] array to int[][] within Java, because Matlab will unbox a Java int[][] back to a Matlab array. Keeping it as Object[] within M-code protects it.

    You could also build a List or other Collection using similar wrappers. That might mesh better with your other Java code, and Collections don’t unbox in Matlab.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array that created 5 objects. Each object has two strings and
I have created an array in php that prints this Array ( [mark] =>
I have created 4 buttons via Interface Builder. I have an array which has
Explanation I have a multidimensional array that is iterated over to created a categorized
Hi I have created a setDecorator() which is something like this: $timeSu->setDecorators(array('ViewHelper', 'Description', 'Errors',
I am a newbie to Java. I have an array of objects that have
I have a program which creates a C structure which contains large arrays of
I have a array which contains values like this See below for script sample
I have created an array of doubles using the following code: double *points =
I have an array that gets created from JSON. The array looks like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.