comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: replacing blocks in an array with other array values?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: replacing blocks in an array with other array values? [message #78818 is a reply to message #78817] Sun, 25 December 2011 15:44 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Ecaterina Coman writes:

> I have a 4*4 array, for example, and i want to replace the center 2*2
> block of an array with the values in another array
>
> lets say A is 4*4
> and B is 2*2
> I tried doing A[1:2,1:2]=B but it doesn't change anything in A
> on the other hand, when I put A[1:2,1:2]=some scalar, it replaces the
> whole block by that scalar and works
>
> i feel like there should be a simple way to do this but cannot figure
> it out

You will have to specify the lower-left corner of the
array, like this:

IDL> a = indgen(4, 4)
IDL> b = indgen(2,2)+20
IDL> a[1,1] = b
IDL> print, a
0 1 2 3
4 20 21 7
8 22 23 11
12 13 14 15

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: replacing blocks in an array with other array values?
Next Topic: Array Subscription

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:32:26 PDT 2025

Total time taken to generate the page: 0.00330 seconds