Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31345

Re: numpy - 2D matrix/array - initialization like in Matlab...

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'initialize': 0.05; 'much!': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'etc...': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:array': 0.16; 'string': 0.17; 'wrote:': 0.17; 'variables': 0.17; 'subject:skip:i 10': 0.22; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints- To:1': 0.28; 'subject:/': 0.28; 'subject:like': 0.29; 'array': 0.29; 'help,': 0.32; 'could': 0.32; 'to:addr:python-list': 0.33; 'received:org': 0.36; 'thank': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'subject:...': 0.63; 'skip:n 10': 0.63; 'received:12': 0.81
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Emile van Sebille <emile@fenx.com>
Subject Re: numpy - 2D matrix/array - initialization like in Matlab...
Date Mon, 15 Oct 2012 14:52:26 -0700
References <k5hu2e$h5i$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host 12.184.110.78
User-Agent Thunderbird 2.0.0.24 (Windows/20100228)
In-Reply-To <k5hu2e$h5i$1@dont-email.me>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2243.1350337892.27098.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1350337892 news.xs4all.nl 6946 [2001:888:2000:d::a6]:36740
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31345

Show key headers only | View raw


someone wrote:
> How to initialize my array directly using variables ?
> 
> It could also be that I wanted:
> 
> test11 = 1
> test12 = 1.5
> test13 = 2
> test21 = 0
> test22 = 5
> 
> Dx = numpy.matrix('test11 test12 test13; test21 test22 -0.5; 0 -0.5 1.5')
> 
> Etc... for many variables...
> 
> Appreciate ANY help, thank you very much!

You could use string interpolation:

Dx = numpy.matrix('%s %s %s; %s %s -0.5; 0 -0.5 1.5'
               % (test11 test12 test13 test21 test22))


Emile

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

numpy - 2D matrix/array - initialization like in Matlab... someone <newsboost@gmail.com> - 2012-10-15 23:09 +0200
  Re: numpy - 2D matrix/array - initialization like in Matlab... MRAB <python@mrabarnett.plus.com> - 2012-10-15 22:26 +0100
    Re: numpy - 2D matrix/array - initialization like in Matlab... someone <newsboost@gmail.com> - 2012-10-16 00:42 +0200
      Re: numpy - 2D matrix/array - initialization like in Matlab... Marco Nawijn <nawijn@gmail.com> - 2012-10-16 03:34 -0700
      Re: numpy - 2D matrix/array - initialization like in Matlab... Marco Nawijn <nawijn@gmail.com> - 2012-10-16 03:34 -0700
  Re: numpy - 2D matrix/array - initialization like in Matlab... Emile van Sebille <emile@fenx.com> - 2012-10-15 14:52 -0700

csiph-web