Re: Table extraction
- To: mathgroup at smc.vnet.net
- Subject: [mg19208] Re: Table extraction
- From: "Roberto Abraham" <abraham at ast.cam.ac.uk>
- Date: Tue, 10 Aug 1999 02:52:58 -0400
- References: <7odkbs$7mq@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
The dimensionality of your example is a little tricky, in that you've got a data cube in your examples rather than 2-D arrays which is what I usually work with, but stitching an array into another array is easy and I think generalizes to higher dimension easily. I think the syntax you are looking for is just something like: xyvector[[Range[a,b],Range[b,c]]] To then stitch this sub-array into another array is a little trickier. I've written a function that sticks an array into another array at a given row and column position that might generalize to what you want to do: stitchIntoImage[big_, little_, r_, c_] := Module[{i, j, nr, nc, bigIndices, littleIndices}, nr = Dimensions[little][[1]]; nc = Dimensions[little][[2]]; bigIndices = Partition[ Flatten[Table[{i, j}, {i, r, r + nr - 1}, {j, c, c + nc - 1}]], 2]; littleIndices = Partition[Flatten[Table[{i, j}, {i, 1, nr}, {j, 1, nc}]], 2]; ReplacePart[big, little, bigIndices, littleIndices]]; Appended below is an example of how to use this function to stick one array into another array at a specified row and column position. Best regards --- Bob Abraham (* Example of sticking one array in another array *) bigImage = Table[Sin[i/10.] Cos[j/10.], {i, 1., 100}, {j, 1., 100}]; ListDensityPlot[bigImage, Mesh -> False]; ListDensityPlot[bigImage[[Range[20, 50], Range[40, 90]]], Mesh -> False, AspectRatio -> Automatic]; littleImage = Table[Cos[i/2.], {i, 1., 20}, {j, 1., 20}]; ListDensityPlot[littleImage, Mesh -> False] ListDensityPlot[stitchIntoImage[bigImage, littleImage, 10, 10], Mesh -> False] Maurice Shevalier <maurice at phas.ucalgary.ca> wrote in message news:7odkbs$7mq at smc.vnet.net... > Hi, > > I am trying to extract a section of a table with not much luck.... > > I have defined two tables (actually two arrays which are used to plot > vectors with ListPlotVectorField) as follows: > > xyvector = Table[{0.,0.},{j,1,64},{i,1,320}]; > backvector = Table[{0.,0.},{j,1,16},{i,1,100}]; > > I need to extract part of xyvector and place it into backvector. I have > tried to use Part. I can extract the j range correctly (rows), but I > can't get the Part function to extract in the i range (columns). > > I tried using Part[xyvector,{2,3}] which extracts 2 rows but I cannot > figute out how to extract the necessary columns > > Can anyone help? > > Thanks, > > Maurice > > -- > Maurice Shevalier | .~. > Ph.D. Candidate | /V\ L I N U X > Dept. of Physics and Astronomy | // \\ >The Penguin, The Slayer?< > University of Calgary | /( )\ > Calgary, AB, CANADA T2N-1N4 | ^^-^^ > (403)220-7873 fax:(403)284-0074 | > e-mail: maurice at phas.ucalgary.ca > > > >