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 6115231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:04:03+00:00 2026-05-23T15:04:03+00:00

I am trying to import data from a saved MATLAB struct array, but it

  • 0

I am trying to import data from a saved MATLAB struct array, but it seems that Mathematica is only importing the first element.

MATLAB

blank = struct('x', [], 'y', [], 'z', []);
data = repmat(blank, 1, 10);

for i = 1:10
    data(i) = struct('x', i, 'y', i * 2, 'z', i * 3);
end

save('test.mat', 'data');

Mathematica

In[76]:= Import["test.mat", "LabeledData"]
Out[76]= {"data" -> {"x" -> {{1.}}, "y" -> {{2.}}, "z" -> {{3.}}}}

Does anyone know why this is happening?

As a temporary fix, I’ve simply resorted to storing multiple struct’s in a cell array, i.e.

data{i} = struct(...)

Mathematica seems to be able to handle that fine.

  • 1 1 Answer
  • 0 Views
  • 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-23T15:04:04+00:00Added an answer on May 23, 2026 at 3:04 pm

    I can’t really explain the behavior but in order to be able to read the files in Mathematica it is better to specify the Matlab version you are using. In MATLAB try the saving data with version 6.

    >> save('test.mat', '-v6', 'data')
    

    Then in mathematica:

    In[1]:= Import["test.mat", "LabeledData"]
    Out[1]= {"data" -> {"x" -> {{1.}}, "y" -> {{2.}}, "z" -> {{3.}}}, {{2.}}, {{4.}}, {{6.}}, {{3.}}, {{6.}}, {{9.}}, {{4.}}, {{8.}}, {{12.}}, {{5.}}, {{10.}}, {{15.}}, {{6.}}, {{12.}}, {{18.}}, {{7.}}, {{14.}}, {{21.}}, {{8.}}, {{16.}}, {{24.}}, {{9.}},{{18.}}, {{27.}}, {{10.}}, {{20.}}, {{30.}}}
    

    I tried saving with v4 but that doesn’t work in MATLAB. Notice that the documentation in Mathematica says that “Import fully supports Versions 4 and 5 of the MAT format.”. I Hope this helps.

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

Sidebar

Related Questions

I'm trying to import XML data from an excel spreadsheet (saved as an 'XML
I’m trying to import fixed width data from text file into SQL Server Express
In this situation I am trying to perform a data import from an XML
I am trying to import the contact list from gmail using libgmailer.php but I
I'm using C# and .NET 3.5, trying to import some data from old dbf
I imported data from MySQL to a CSV. Now I am trying to import
I am trying to import an excel file into a data table using GemBox
I am trying to import a csv file to insert data into an existing
Im trying push some data into a CRM system via an XML import. I
I'm trying to write an import function for getting data out of an excel

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.