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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:10:25+00:00 2026-05-26T11:10:25+00:00

I can’t seem to find any standard functions for serializing data. I have a

  • 0

I can’t seem to find any standard functions for serializing data. I have a large 128×51 array that I need need to store in a single database field. Without some kind of serializing, things will be problematic.

Whats the best way to solve this? I don’t use matlab quite that much so I’m not familiar with standard procedures…

  • 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-26T11:10:26+00:00Added an answer on May 26, 2026 at 11:10 am

    One possibility is to use the TYPECAST function to convert numeric values into UINT8 bytes (only works for full, non-complex numeric values).

    Note that the matrix has to be reshaped into a vector prior to serialization, thus its size will also have to be separately stored (or even serialized using the same process):

    %# sample matrix
    M = rand(3,4);
    
    %# convert
    b_sz = typecast(size(M),'uint8');   %# serialized matrix size
    b = typecast(M(:),'uint8');         %# serialized vector
    

    Now you can store b and b_sz into the database as sequences of bytes (integers in the range [0,255])

    >> whos b b_sz
      Name       Size            Bytes  Class    Attributes
    
      b         96x1                96  uint8              
      b_sz      16x1                16  uint8          
    

    Next, when you retrieve those values from DB, you can convert them back to double values using the inverse procedure, and reshape the matrix to its original size:

    MM = reshape(typecast(b,'double'), typecast(b_sz,'double'));
    
    %# compare against original matrix
    isequal(M,MM)
    

    Optionally, if your database does not support array types, you can just convert the byte sequence as string, and store it in a VARCHAR type of field:

    %# as string
    str = sprintf('%d ',b);
    
    %# recover bytes from string
    b = uint8(str2num(str));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can I have a project that has some parts written in c and other
Can some one confirm me that only one UIWindow instance is possible in any
Can somebody point me to a resource that explains how to go about having
Can a LINQ enabled app run on a machine that only has the .NET
I have a jquery bug and I've been looking for hours now, I can't
Can I call select before recv_from on a socket that is blocking?
Can anyone suggest how to underline the title of a UIButton ? I have
Can someone maybe tell me why this is not working? I have used echo
Can anybody tell me a regular expression to use within some PHP to find

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.