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

  • Home
  • SEARCH
  • 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 8722469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:25:38+00:00 2026-06-13T07:25:38+00:00

What is the difference between cell (i.e. with { } ) and matrix (i.e.

  • 0

What is the difference between cell (i.e. with { }) and matrix (i.e. with [ ]) in Matlab?

  • 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-06-13T07:25:39+00:00Added an answer on June 13, 2026 at 7:25 am

    There are several differences between a cell array and a matrix in MATLAB:

    • A cell array may contain any arbitrary type of element in each cell; while a matrix requires the types of its elements to be homogeneous i.e. of the same type.

    • As far as memory layout goes, all elements of a matrix are laid out contiguously in memory, while a cell array contains pointers to each element of the array. This can be important when considering things like cache locality for high performance code.

    • The flip side of point 2 is that when you resize a matrix every element in the matrix must be copied over to the newly allocated memory area, but in case of a cell array only a list of pointers needs to copied over. Depending on the size and type of elements you’re storing, this might mean cell arrays are much faster to resize.


    To illustrate the differences in memory layout, let’s consider a simple example:

    A = [10 20 30 40];
    

    Here MATLAB creates a new matrix variable named A, allocates enough memory to hold 4 doubles (32 bytes, assuming 8 byte doubles) and assigns this memory to a pointer that points to the real part of A. (If you create a matrix of complex numbers, memory is allocated for the imaginary part also, and a separate pointer points to this memory area).

    Now let’s create a cell array that holds these elements:

    B = cell(1, 4);
    B{1,1} = 10;
    B{1,2} = 20;
    B{1,3} = 30;
    B{1,4} = 40;
    

    When MATLAB executes the first statement, it creates a cell array that contains 4 pointers, each of which can point to an arbitrary type. So B is already using 16 bytes (assuming 32-bit pointers).
    The next line creates a 1×1 matrix containing the value 10 and assigns it to the first cell array element. The process here is similar to the one I described above for creation of a 1×4 matrix, except that the memory allocated is only large enough to hold one double (8 bytes). This is repeated for each of the remaining 3 statements. So, at the bare minimum, the second example uses 16 + 8 x 4 = 48 bytes.

    Note that each variable in MATLAB also includes memory overhead for a structure called an mxArray that stores information such as dimension, data type and a lot more about that variable. I’ve ignored this overhead for the sake of simplicity.

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

Sidebar

Related Questions

Can someone explain the difference between static NSString* CellIdentifier = @Cell; and NSString *CellIdentifier
What is the difference between accessing elements in a cell array using parentheses ()
What's the difference (if indeed there is a difference) between: UITableViewCell *cell; ... cell.textLabel.text
Difference between start-pointers and interior-pointers and in what situation we should prefer one over
The difference between Chr and Char when used in converting types is that one
What's the difference between CopyIcon and DuplicateIcon ?
JAVA : is there a difference between the two references p && pp? PrintStream
What are the difference between a public class member class data { public: std::list<data>
Can any one explain difference between position and anchor point in cocos-2D with some
Is there any tangible difference between the two forms of syntax available for creating

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.