Skip to content
Prev 31315 / 398513 Next

Help to make a simple function

Hi all,

I try to make a program for comparison between matrix cells.

Here um simple example:

3 |a b a
2 |b b b
1 |a b a
  -------
   1 2 3

This is tabulated like this:

x y sp
1 1 a
1 2 b
1 3 a
2 1 b
2 2 b
2 3 b
3 1 a
3 2 b
3 3 a

Then, I need to make the follow calcule:

==============================================
Change in sp levels from 1x1 area to 2x2 area:
----------------------------------------------
from (1:1) to (1:2) change of the "a" to "b"
change count = 1

from (1:1) to (2:2) change of the "a" to "b"
change count = 1

from (1:1) to (2:1) change of the "a" to "b"
change count = 1
----------------------------------------------
Total change counts = 3
==============================================

==============================================
Change in sp levels from 2x2 area to 3x3 area:
----------------------------------------------
from (1:2) to (1:3) change of the "b" to "a"
change count = 1

from (1:2) to (2:3) change of the "b" to "b" (not change)
change count = 0

from (2:2) to (1:3) change of the "b" to "a"
change count = 1

from (2:2) to (2:3) change of the "b" to "b"
change count = 0

from (2:2) to (3:3) change of the "b" to "a"
change count = 1

from (2:2) to (3:2) change of the "b" to "b"
change count = 0

from (2:2) to (3:1) change of the "b" to "a"
change count = 1
----------------------------------------------
Total change counts = 4
==============================================

The result is a table like this

area changecounts
1      0
4      3
9      4

Anybody have any idea for solve this?

Any sugestions?

Thanks for all

Ronaldo