×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to test and average the surrounding non-zeros elements

How to test and average the surrounding non-zeros elements

How to test and average the surrounding non-zeros elements

(OP)

Hi guys,

Here is the problem:

Say if I have a matrix that looks like:

new_x =

     0         0          0          0         0
     0         0     **9.0000**    9.0000      0
     0      4.0000     9.0000    **9.0000**    0
     0    **8.3333** **8.0000**      0         0
     0      2.0000     4.0000      8.0000      0
     0      4.0000     5.0000      8.0000      0
     0         0          0          0         0

Where **value** means the centre.

I want to test if the neighbor elements are equal, lesser, or greater than the centre. If it is greater or equal then '1' or else '0'. The neighbor elements depend on the radius.

For example,

For radius =1 m = 1 element away from the centre, test_x = [(i+1,j) , (i-1,j) , (i,j+1) and (i,j-1)] - top, bottom, right, and left of the centre.

For radius =2 m = 2 elements away, test_x = [(i+1,j), (i+2,j) , (i-1,j) , (i-2,j), (i,j+1), (i,j+2), (i,j-1), (i,j-2), (i+1,j+1), (i+1,j-1), (i-1,j-1), and (i-1,j+1)].


Note: if the neighbors are with in the radius of the two or more centres, take the smallest centre average to test.

    0    12     9      
    4  **9**    15      
   11    19     0  

The '9' in the middle is within the radius of 12, 15, and 19 centres, so take the minimum average of those min[9.000, 9.000, 8.000]=8.000

For example, when radius = 1 m or 1 element away.

new_x =

     0         0          0          0         0
     0         0     **9.0000**    9.0000      0
     0      4.0000     9.0000    **9.0000**    0
     0    **8.3333** **8.0000**      0         0
     0      2.0000     4.0000      8.0000      0
     0      4.0000     5.0000      8.0000      0
     0         0          0          0         0

Test_x =

     0         0           0           0         0
     0         0       **9.0000**      1         0
     0         0           1       **9.0000**    0
     0    **8.3333**   **8.0000**      0         0
     0         0           0           0         0
     0         0           0           0         0
     0         0           0           0         0


I have tried a few things before, however I am not familiar with the functions.

So please help me to solve the problem.

Thank you in advance.
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close