Simplifying a four-dimensional rule table in Matlab: addressing rows and columns of each dimension

Posted by Cate on Stack Overflow See other posts from Stack Overflow or by Cate
Published on 2010-06-01T12:20:32Z Indexed on 2010/06/01 12:23 UTC
Read the original article Hit count: 247

Filed under:
|
|
|
|

Hi all.

I'm currently trying to automatically generate a set of fuzzy rules for a set of observations which contain four values for each observation, where each observation will correspond to a state (a good example is with Fisher's Iris Data).

In Matlab I am creating a four dimensional rule table where a single cell (a,b,c,d) will contain the corresponding state. To reduce the table I am following the Hong and Lee method of row and column similarity checking but I am having difficulty understanding how to address the third and fourth dimensions' rows and columns. From the method it is my understanding that each dimension is addressed individually and if the rule is true, the table is simplified. The rules for merging are as follows:

  1. If all cells in adjacent columns or rows are the same.
  2. If two cells are the same or if either of them is empty in adjacent
    columns or rows and at least one cell in both is not empty.
  3. If all cells in a column or row are empty and if cells in its two
    adjacent columns or rows are the same, merge the three.
  4. If all cells in a column or row are empty and if cells in its two
    adjacent columns or rows are the same or either of them is empty, merge the three.
  5. If all cells in a column or row are empty and if all the non-empty
    cells in the column or row to its left have the same region, and all the non-empty cells in the column or row to its right have the same region, but one different from the previously mentioned region, merge these three columns into two parts.

Now for the confusing bit. Simply checking if the entire row/column is the same as the adjacent (rule 1) seems simple enough:

if (a,:,:,:) == (a+1,:,:,:)
   (:,b,:,:) == (:,b+1,:,:)
   (:,:,c,:) == (:,:,c+1,:)
   (:,:,:,d) == (:,:,:,d+1)

is this correct?

but to check if the elements in the row/column match, or either is zero (rules 2 and 4), I am a bit lost. Would it be something along these lines:

for a = 1:20
    for i = 1:length(b)
        if (a+1,i,:,:) == (a,i,:,:)
        ...
        else if (a+1,i,:,:) == 0
        ...
        else if (a,i,:,:) == 0      etc.

and for the third and fourth dimensions:

for c = 1:20
    for i = 1:length(a)
        if (i,:,c,:) == (i,:,c+1,:)
        ...
        else if (i,:,c+1,:) == 0
        ...
        else if (i,:,c,:) == 0      etc.

for d = 1:20
    for i = 1:length(a)
        if (i,:,:,d) == (i,:,:,d+1)
        ...
        else if (i,:,:,d+1) == 0
        ...
        else if (i,:,:,d) == 0      etc.

even any help with four dimensional arrays would be useful as I'm so confused by the thought of more than three! I would advise you look at the paper to understand my meaning - they themselves have used the Iris data but only given an example with a 2D table.

Thanks in advance, hopefully!

© Stack Overflow or respective owner

Related posts about table

Related posts about matlab