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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:58:29+00:00 2026-06-01T19:58:29+00:00

When I use Python to model a 3-Dimensional matrix, I first make a multi-array

  • 0

When I use Python to model a 3-Dimensional matrix, I first make a multi-array of zeros. Then, I can easily overwrite each element by referencing its index. The problem is, the order of indices change when trying to reference multiple elements using [:]. I’m going to speak in matrix math jargon, so bear with me.

In the example below, I want to model the position of an object in the 2-D plane per time level. So for each time level, I have an X (row) and Y (column) coordinate. In the example below, I use two time levels with 3 rows and 4 columns.

    >>> Simple = numpy.zeros([2,3,4],float)
    >>> print Simple
    [[[ 0.  0.  0.  0.]
    [ 0.  0.  0.  0.]
    [ 0.  0.  0.  0.]]

    [[ 0.  0.  0.  0.]
    [ 0.  0.  0.  0.]
    [ 0.  0.  0.  0.]]]

Looks good. I have two 3×4 matrices. Now I want to change the value of the 2nd matrix (2nd time level), 3rd row, 4th column to be equal to 9.

    >>> Simple[1][2][3] = 9
    >>> print Simple
    [[[ 0.  0.  0.  0.]
    [ 0.  0.  0.  0.]
    [ 0.  0.  0.  0.]]

    [[ 0.  0.  0.  0.]
    [ 0.  0.  0.  0.]
    [ 0.  0.  0.  9.]]]

So far so good. From this, I can tell that the order of indices is Simple[TimeLevel,X,Y]. So now, for each time level, I want the element in the first row, second column (timelevel = both,x=0,y=1) to be the number “4”.

   >>> Simple[:][0][1] = 4
   >>> print Simple
   [[[ 0.  0.  0.  0.]
   [ 4.  4.  4.  4.]
   [ 0.  0.  0.  0.]]

   [[ 0.  0.  0.  0.]
   [ 0.  0.  0.  0.]
   [ 0.  0.  0.  9.]]]

So as you can see, the order of indices is no longer the same. It switched from Simple[TimeLevel,row,column] to Simple[column,TimeLevel,row].

My question is: WHY?

  • 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-01T19:58:31+00:00Added an answer on June 1, 2026 at 7:58 pm

    All [:] does is return a copy of the sequence. This is not what you want.

    >>> Simple[:,0,1] = 4
    >>> Simple
    array([[[ 0.,  4.,  0.,  0.],
            [ 0.,  0.,  0.,  0.],
            [ 0.,  0.,  0.,  0.]],
    
           [[ 0.,  4.,  0.,  0.],
            [ 0.,  0.,  0.,  0.],
            [ 0.,  0.,  0.,  0.]]])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

pypy has many built-in function use python implementation.example: link but,i can't find model 'sys'
I'm attempting to use Python to convert a multi-page PDF into a series of
Automapper is a object-object mapper where we can use to project domain model to
I would like to wrap a non-Traits model class for use with Python Traits.
I use this code to define my class in GAE Python: class Pair(db.Model): find
Can anyone please post a Python example that demonstrates the use of a request/response
I use python debugger pdb. I use emacs for python programming. I use python-mode.el.
We use Python 3.x in our projects. But the official client of Protocol Buffers
I use Python 2.6 more than I use Leopard's default python installation, so I
I use python to process web page. I download the souce code of the

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.