Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Consecutive variables from matrix
Replies: 1   Last Post: Jan 8, 2013 11:43 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Jesse Pisel

Posts: 3
Registered: 11/14/12
Consecutive variables from matrix
Posted: Jan 7, 2013 11:04 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.