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


Groups > comp.soft-sys.math.mathematica > #3360

Re: Table with conditions

From Peter Breitfeld <phbrf@t-online.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Table with conditions
Date 2011-06-29 21:32 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iug5m0$9fn$1@smc.vnet.net> (permalink)
References <iu71je$1aq$1@smc.vnet.net>

Show all headers | View raw


"J. Jesus Rico Melgoza" wrote:

> I am constructing a Table
>
> h=60
> hi=60
> P1 = Flatten[
>     Table[{Pk[k].Fl[l], k + l}, {k, -h, 
>       h}, {l, -hi, hi}], 1]
> This yields a table with two columns. First column contains vector of order n and column 2 contains an scalar
> I want to add conditions to generate the elements in the Table
> -h<=k+l<=h. 
> I do not know how to do this with the function Table[..] of Mathematica. I am asking for your help.
> I do not want rows in my table that do not satisfy the condition.  
>
> Pk[k] is matrix and Fl[l] is a column vector
>
> Thanks in advance
>
> Jesus Rico-Melgoza
>

This seams to work:

h = 60; hi = 60;
p1 = Table[{Pk[k].Fl[l], k + l}, {k, -h, h}, {l, -hi, hi}]
Flatten[Select[#, -h <= #[[2]] <= h &] & /@ p1, 1] // TableForm


-- 
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

Back to comp.soft-sys.math.mathematica | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Table with conditions "J. Jesus Rico Melgoza" <jerico@umich.mx> - 2011-06-26 10:27 +0000
  Re: Table with conditions Peter Breitfeld <phbrf@t-online.de> - 2011-06-29 21:32 +0000

csiph-web