Skip to main content
Tweeted twitter.com/StackMma/status/1169445114999164928
Became Hot Network Question
typo
Source Link
MelaGo
  • 9.1k
  • 1
  • 11
  • 26

I have a 2-level list in the form of a $m\times n$ matrix: {{a11,a12,a13,...,a1n},{a21,a22,a23,...,a2n}, ..., {am1,am2,am3,...,amn}}, in which the numbers are normally decimals. Now, I need to compare each element in the $(n+1)$-th level to the corresponding element in the $n$-th level (i.e., the previous level). If the element in the $(n+1)$-th level is larger than that of the $n$-th level, it gives a $+$ sign; if the absolute of the difference between the two numbers is smallsmaller than a small value, say, $0.001$, it gives a $=$ sign; otherwise a $-$ sign. The comparison should be carried out up to the last sub-list to generate a "$+/-/=$" sign table in a $(m-1)\times n$ matrix from finally.

For example, given a list of lists:

{{1.1, 2.3 ,3.4, 4.3, 5.01},{2.1, 1.2, 2.5, 5.6, 5.001},{1.2, 1.201, 1.2, 6.3, 3.7}}

Supposing a function will do the job. After the above manipulation, the desired function should give the following $2\times 5$ matrix {{+,-,-,+,=}, {-,=,-,+,-}}.

Can somebody please help me to do this with MMA. Thank you in advance.

I have a 2-level list in the form of a $m\times n$ matrix: {{a11,a12,a13,...,a1n},{a21,a22,a23,...,a2n}, ..., {am1,am2,am3,...,amn}}, in which the numbers are normally decimals. Now, I need to compare each element in the $(n+1)$-th level to the corresponding element in the $n$-th level (i.e., the previous level). If the element in the $(n+1)$-th level is larger than that of the $n$-th level, it gives a $+$ sign; if the absolute of the difference between the two numbers is small than a small value, say, $0.001$, it gives a $=$ sign; otherwise a $-$ sign. The comparison should be carried out up to the last sub-list to generate a "$+/-/=$" sign table in a $(m-1)\times n$ matrix from finally.

For example, given a list of lists:

{{1.1, 2.3 ,3.4, 4.3, 5.01},{2.1, 1.2, 2.5, 5.6, 5.001},{1.2, 1.201, 1.2, 6.3, 3.7}}

Supposing a function will do the job. After the above manipulation, the desired function should give the following $2\times 5$ matrix {{+,-,-,+,=}, {-,=,-,+,-}}.

Can somebody please help me to do this with MMA. Thank you in advance.

I have a 2-level list in the form of a $m\times n$ matrix: {{a11,a12,a13,...,a1n},{a21,a22,a23,...,a2n}, ..., {am1,am2,am3,...,amn}}, in which the numbers are normally decimals. Now, I need to compare each element in the $(n+1)$-th level to the corresponding element in the $n$-th level (i.e., the previous level). If the element in the $(n+1)$-th level is larger than that of the $n$-th level, it gives a $+$ sign; if the absolute of the difference between the two numbers is smaller than a small value, say, $0.001$, it gives a $=$ sign; otherwise a $-$ sign. The comparison should be carried out up to the last sub-list to generate a "$+/-/=$" sign table in a $(m-1)\times n$ matrix from finally.

For example, given a list of lists:

{{1.1, 2.3 ,3.4, 4.3, 5.01},{2.1, 1.2, 2.5, 5.6, 5.001},{1.2, 1.201, 1.2, 6.3, 3.7}}

Supposing a function will do the job. After the above manipulation, the desired function should give the following $2\times 5$ matrix {{+,-,-,+,=}, {-,=,-,+,-}}.

Can somebody please help me to do this with MMA. Thank you in advance.

Source Link
user55777
  • 643
  • 3
  • 17

Comparing elements in a nested list to generate a new list

I have a 2-level list in the form of a $m\times n$ matrix: {{a11,a12,a13,...,a1n},{a21,a22,a23,...,a2n}, ..., {am1,am2,am3,...,amn}}, in which the numbers are normally decimals. Now, I need to compare each element in the $(n+1)$-th level to the corresponding element in the $n$-th level (i.e., the previous level). If the element in the $(n+1)$-th level is larger than that of the $n$-th level, it gives a $+$ sign; if the absolute of the difference between the two numbers is small than a small value, say, $0.001$, it gives a $=$ sign; otherwise a $-$ sign. The comparison should be carried out up to the last sub-list to generate a "$+/-/=$" sign table in a $(m-1)\times n$ matrix from finally.

For example, given a list of lists:

{{1.1, 2.3 ,3.4, 4.3, 5.01},{2.1, 1.2, 2.5, 5.6, 5.001},{1.2, 1.201, 1.2, 6.3, 3.7}}

Supposing a function will do the job. After the above manipulation, the desired function should give the following $2\times 5$ matrix {{+,-,-,+,=}, {-,=,-,+,-}}.

Can somebody please help me to do this with MMA. Thank you in advance.