Re: (no subject)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

MONTAGU Thierry
hi,

thank you for answering and sorry, for posting wrong code.

here is a working matlab/octave code :

a = [] % or a = zeros(10)
m = 23
a(3).m = 22

my question remain the same.

Kind Regards

Thierry

>
> ------------------------------
>
> Message: 4
> Date: Mon, 17 Jan 2011 10:26:29 +0100
> From: MONTAGU Thierry<[hidden email]>
> Subject: [SciPy-User] how to do easy things in octave with numpy ?
> To: [hidden email]
> Message-ID:<[hidden email]>
> Content-Type: text/plain; charset=ISO-8859-15; format=flowed
>
> Hi all scipy user
>
> i wonder how to do the following easy thing in octave within a
> python/numpy script.
>
> in octave:matlab, you instantiate
>
> a= zeros(10) for example
>
> and for example, you can do in one line
> a[2].m = 10
>
> or do
>
> for i = 1 : length(a)
>        a[i].m = 25;
> end
>
> How to do this with numpy ? I guess we need to create a python class ?
> any idea ?
>
> Regards
>

--
Thierry Montagu
CEA Saclay
DRT/LIST/DCSI/LM2S
bât. 516 P
91191 Gif sur Yvette
01 69 08 88 19


_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

eat-3
MONTAGU Thierry <thierry.montagu <at> cea.fr> writes:
Hi,
>
> hi,
>
> thank you for answering and sorry, for posting wrong code.
>
> here is a working matlab/octave code :
>
> a = [] % or a = zeros(10)
> m = 23
What is the point of the above rows?

> a(3).m = 22
This seem to be structure array in Octave, so you could use for example numpy
recarray
In [1]: a= recarray((10,), dtype= [('m', int)])

In [2]: for i in xrange(a.size):
   .....:     a[i].m= 25

Recarray is only one alternative to use, therefore it would be much more
beneficial if you could provide a small working example in Octave inorder to
figure out more suitable python translation.


Regards,
eat

>
> my question remain the same.
>
> Kind Regards
>
> Thierry
>
> >
> > ------------------------------
> >
> > Message: 4
> > Date: Mon, 17 Jan 2011 10:26:29 +0100
> > From: MONTAGU Thierry<thierry.montagu <at> cea.fr>
> > Subject: [SciPy-User] how to do easy things in octave with numpy ?
> > To: scipy-user <at> scipy.org
> > Message-ID:<4D340B45.10600 <at> cea.fr>
> > Content-Type: text/plain; charset=ISO-8859-15; format=flowed
> >
> > Hi all scipy user
> >
> > i wonder how to do the following easy thing in octave within a
> > python/numpy script.
> >
> > in octave:matlab, you instantiate
> >
> > a= zeros(10) for example
> >
> > and for example, you can do in one line
> > a[2].m = 10
> >
> > or do
> >
> > for i = 1 : length(a)
> >        a[i].m = 25;
> > end
> >
> > How to do this with numpy ? I guess we need to create a python class ?
> > any idea ?
> >
> > Regards
> >
>




_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Chris Barker - NOAA Federal
On 1/18/11 1:25 AM, eat wrote:
>> a = [] % or a = zeros(10)
>> m = 23
> What is the point of the above rows?
>
>> a(3).m = 22
> This seem to be structure array in Octave,

Does Octave give you arrays of structures with zeros(10)?

>so you could use for example numpy
> recarray
> In [1]: a= recarray((10,), dtype= [('m', int)])
>
> In [2]: for i in xrange(a.size):
>     .....:     a[i].m= 25
>
> Recarray is only one alternative to use, therefore it would be much more
> beneficial if you could provide a small working example in Octave inorder to
> figure out more suitable python translation.

or better yet, a description of what you need to do - very rarely does
'translating' directly from one language to another get you the best
result. For the most part, python/numpy is more powerful and flexible
than Matlab/Octave, so there can be whole new ways of doing things.

-Chris




--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]
_______________________________________________
SciPy-User mailing list
[hidden email]
http://mail.scipy.org/mailman/listinfo/scipy-user