"Roger Stafford" wrote in message <ivvtms$dil$1@newscl01ah.mathworks.com>...
> "curoch" wrote in message <ivv7va$kan$1@newscl01ah.mathworks.com>...
> > ........
> > A = [1 1 23
> > 1 1 24
> > 1 1 34
> > 1 1 45
> > 2 1 77
> > 2 1 12
> > 2 1 4 ]
> >
> >  My aim is to analyse the elements in the third column for each set where the values in column 1 and 2 are equal.
> >  Upon analysing, I need to delete the row which has the smallest value in column 3.
> >
> > For example, applying this to matrix A
> >
> > The first set is [ 1 1 23
> > 1 1 24] hence deleting the first row
> >
> > Matrix A thus becomes
> >
> > A = [ 1 1 23
> > 1 1 34
> > 2 1 12
> > 2 1 4]
> > ......
>          
> Perhaps you should clarify your question, Curoch. You stated "I need to delete the row which has the smallest value in column 3" but then you proceeded to delete the larger one instead. Also you haven't said what is to happen if three or more rows have column 1 all alike and column 2 all alike. How many are to be deleted and which one(s)? In the case of the single row with 2 and 1 you didn't delete anything at all, so what is the proper generalization?
>
> Roger Stafford
Dear Roger,
Thank you for replying. It appears as you have stated that my post contains some inaccuracies which obviously makes it harder for you guys to help me. I hope this post will make everything clear.
1. I should have said "Delete the row with the largest element in Column 3" thus deleting the 2nd row with element 24 in column 3. My apologies. Unfortunately, I cannot edit my previous post so please ignore it.
2. In terms of proper generalisation, the best way I can explain is by partitioning the matrix. A new example
B = [ 1 1 123
1 1 434
1 1 111
1 1 434
1 1 666
2 1 12
2 1 44
2 1 33 ]
I need to analyse each set within matrix B where the element in column 1 is equal. So the first set is as follows
[ 1 1 123, 1 1 434, 1 1 111, 1 1 434, 1 1 666]
Within each set, I need to first of all analyse the rows where the elements in column 1 and 2 are equal. Therefore [1 1 123, 1 1 434, 1 1 111].
From there, I need to keep the row with the smallest element in column 3.
I then need to analyse the remaining rows within set 1 which is [1 1 434, 1 1 666], also keeping the row with the smallest element in column 3.
These "sets" or "partitions" vary in length and the same may be said about the inner sets. Some sets have a length of 5, others 2 etc...
3. In the case of a single row (where column 1 = column 2 and column 1 ~= column 2), nothing is performed on the row.
4. To add, for any set of rows, the element in column 3 will never be equal so there will never be an instance when there is no minimum.
Upon successful completion, matrix B will take the following appearance
B = [ 1 1 111
1 1 434
2 1 12
2 1 33]
5. Just to clarify, the elements in column 1 and 2 are more complex than 1 and 1, the matrix could be in this form for instance
C = [ 2.321 2.321 324
2.321 2.321 121
2.321 0.432 111
2.321 0.432 114 ]
6. As a last point, in each set, there are only one possibility when column 1 does not equal column 2.
For instance, the matrix can never take the following form
D = [ 12 0.5 1
12 0.5 2
12 1 3
12 10 4]
I hope this clears everything up,
Do not hesitate to let me know if something needs clarifying,
Regards,
CF
