MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Consecutive variables from matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129359] Consecutive variables from matrix
  • From: Jesse Pisel <jessepisel at gmail.com>
  • Date: Mon, 7 Jan 2013 23:05:20 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

I don't know if I am going about this problem the wrong way or if it is even possible to use this method. I am interested in assigning the different rows of a 4x4 matrix to variables d1-d4 and the first value of a different matrix to a variable t and using the variables in an if then statement. An example of what I am trying to do is:

data1 = RandomReal[{0, 10}, {4, 4}]
data2 = RandomReal[{0, 10}, {4, 4}]
t = data2[[1, 1]]
d1 = data1[[1, 1]]
d2 = data1[[1, 2]]
d3 = data1[[1, 3]]
d4 = data1[[1, 4]]
If[t < d1 \[And] t < d2 \[And] t < d3 \[And] t < d4, 0, 1]

But what I want to do is run through the first row of values in the data2 with the first row of values from data1 without having to write out all the different possible combinations eg:

data1 = RandomReal[{0, 10}, {4, 4}]
data2 = RandomReal[{0, 10}, {4, 4}]
t = data2[[1, 1]]
d1 = data1[[1, 1]]
d2 = data1[[1, 2]]
d3 = data1[[1, 3]]
d4 = data1[[1, 4]]
If[t < d1 \[And] t < d2 \[And] t < d3 \[And] t < d4, 0, 1]

data1 = RandomReal[{0, 10}, {4, 4}]
data2 = RandomReal[{0, 10}, {4, 4}]
t = data2[[1, 2]]
d1 = data1[[1, 1]]
d2 = data1[[1, 2]]
d3 = data1[[1, 3]]
d4 = data1[[1, 4]]
If[t < d1 \[And] t < d2 \[And] t < d3 \[And] t < d4, 0, 1]

and so on for all the different combinations without having to use brute force. So in review I would like to be able to assign variables d1,d2,d3,d4 to the values in the first row, compare to variable t assigned to the first then second then third and fourth entries of the other matrix and then move to the next row in both matrices. Essentially reassigning the variables d1,d2,d3,d4 and t as the notebook runs.

Any ideas on how to accomplish this and have the output in matrix/list form would be much appreciated.

Thanks 



  • Prev by Date: Mathematica GeoDistance function performance ...oo
  • Next by Date: Re: How to speed up FindRoot with Map or MapThread
  • Previous by thread: Mathematica GeoDistance function performance ...oo
  • Next by thread: Re: Consecutive variables from matrix