The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Array of array
Replies: 14   Last Post: Dec 29, 2012 12:23 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 9,850
Registered: 6/7/07
Re: Array of array
Posted: Dec 26, 2012 10:02 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 12/26/2012 4:33 AM, CHINEDU wrote:

> dpb, your answer is exactly what I wanted. I actually want to create a 2
> dimensional array whose elements are in turn 3-element arrays i.e. To
> create a matrix A with
> Row 1 = (1,2,3), (2,3,4), (2,4,5)
> Row 2 = (4,5,6), (1,2,2), (0,2,1) etc

If you're going to be using regular arrays (in size), then as Bruno and
Nasser note it'll be much simpler (as you're discovering w/ the
addressing syntax issues) and Matlab will be far more responsive to use
normal arrays instead of cell arrays.

Why the insistence on cell arrays--what's the problem domain/usage?
Perhaps a better data structure would present itself if others knew the
intent here...

> dpb's answer has answered it exactly but I am still having problem of
> accessing the elements. I have understood how to access the one-row type
> through dpo's answer but the 2D access is not still clear. I mean, how
> can I access elements of 2D array whose elements are subarrays? dpo
> please, help.
> I have done something like this A ={[1,2,3],[0,-1,4];[-2,-3,-4],[9,8,7]}
> And am accessing the elements using
> A{r,c}(i) for the i-th element of the r-th column and c-th column eg.
> A{1,2}(2)=-1
> Is this correct?

Yes, to get to a cell content, address the cell in curlies first, then
the element(s) in normal parens after.

doc paren

and look for "multi-level addressing" as a subject in the documentation
for more details...


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.