Dear all,
I am using Excel, 2007. I want to calculate slope for a central cell (as in eg. X) from 8 neighboring cells. As a result, I want to know if the calculation is positive and if its positive then show maximum slope direction. If its negative show -1 or if its 0 then show 0, instead of direction.
For example: 1 2 3
4 X 5
6 7 8
I used following result. I dont know how to write all those conditions but I tried and it shows error.
=IF(((B5-A4)/0.707>0) and IF((B5-A4)/0.707=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),1,IF((B5-B4)/0.5>0 and IF((B5-B4)/0.5 =MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),2,IF((B5-C4)/0.707>0 and IF((B5-C4)/0.707=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),3,IF((B5-A5)/0.5>0 and IF((B5-A5)/0.5=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),4,IF((B5-C5)/0.5>0 and IF((B5-C5)/0.5=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),5,IF((B5-A6)/0.707>0 and IF((B5-A6)/0.707=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),6,IF((B5-B6)/0.5>0 and IF((B5-B6)/0.5=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),7,IF((B5-C6)/0.707>0 and IF((B5-C6)/0.707=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),8,0))))))))))))))))
Please help.
Thank you.
I am using Excel, 2007. I want to calculate slope for a central cell (as in eg. X) from 8 neighboring cells. As a result, I want to know if the calculation is positive and if its positive then show maximum slope direction. If its negative show -1 or if its 0 then show 0, instead of direction.
For example: 1 2 3
4 X 5
6 7 8
I used following result. I dont know how to write all those conditions but I tried and it shows error.
=IF(((B5-A4)/0.707>0) and IF((B5-A4)/0.707=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),1,IF((B5-B4)/0.5>0 and IF((B5-B4)/0.5 =MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),2,IF((B5-C4)/0.707>0 and IF((B5-C4)/0.707=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),3,IF((B5-A5)/0.5>0 and IF((B5-A5)/0.5=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),4,IF((B5-C5)/0.5>0 and IF((B5-C5)/0.5=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),5,IF((B5-A6)/0.707>0 and IF((B5-A6)/0.707=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),6,IF((B5-B6)/0.5>0 and IF((B5-B6)/0.5=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),7,IF((B5-C6)/0.707>0 and IF((B5-C6)/0.707=MAX((B5-A4)/0.707,(B5-B4)/0.5,(B5-C4)/0.707,(B5-A5)/0.5,(B5-C5)/0.5,(B5-A6)/0.707,(B5-B6)/0.5,(B5-C6)/0.707),8,0))))))))))))))))
Please help.
Thank you.