1

I've googled topics about difference between cell array and array and had a vision that cell array actually stores pointers to content of elements.

Operator {} is like & in C, right?

When {} is applied to a variable {var_a,var_b}, we get a 1*2 "cell pointers" array to var_a and var_b? Is there a name for the "cell pointer"?

Does structure array take similar memory arrangement?

Take the example in the matlab document:

patient.name = 'John Doe';
patient.billing = 127.00;
patient.test = [79, 75, 73; 180, 178, 177.5; 172, 170, 169];

patient(2).name = 'Ann Lane';
patient(2).billing = 28.50;
patient(2).test = [68, 70, 68; 118, 118, 119; 172, 170, 169];

so the variable patient is like a 2*3 cell array except the field name?

patientcell{2,3}=...

I was wondering the notion below:

The dot operator in structure makes a deference to its content:

patient(1).test;

=> patientcell{1,3}

right?

2
  • For more insight, I'd recommend digging into the MEX API to get a feel for how the underlying mxArray works behind the scenes - even numeric arrays really only store pointers to their data (it's how the copy-on-write mechanism works, for one thing) Commented Mar 8, 2014 at 13:41
  • I think that to accomplish copy-on-write, numeric arrays just store pointer to the starting element, which is different from cell array. The link in your post is an api list, without detail implementation. It's a pity that mathworks hide these details. Commented Mar 10, 2014 at 8:09

1 Answer 1

1

Preallocation of cell array in matlab

It is reasonable to assume that a cell array is implemented as a continuous array of pointers, each pointing to the actual content of the cell.

How do i define a structure in Matlab

the structure is simply an array of pointer[s]

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for confirming my hesitation that structure contains pointers two. Maybe it's a ambiguous itself about the analogy of 2-dimension cell array to structure array. After all, we don't the implementation beneath, and Mathworks don't take this semantic equivalence about the two.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.