08-02-2016 03:31 AM
hello every body
i have a matrix N*M which some of the elements with only 0 and 1 .
each element which is 1 has (row,column).
I want to find the elments 1 and find the mean of rows which is 1 and also the mean of columns.
thank alot
my email: andisheye20@gmail.com
Solved! Go to Solution.
08-02-2016 03:23 AM
hello every body
i have a matrix N*M which some of the elements with only 0 and 1 .
each element which is 1 has (row,column).
I want to find the elments 1 and find the mean of rows which is 1 and also the mean of columns.
thank alot
my email: andisheye20@gmail.com
08-02-2016 03:44 AM - edited 08-02-2016 04:01 AM
Could you create sample matrix with elements of how you are describing and mean of it how it should be calculated?
If i understand correctly your question,
-Matrices are nothing but 2D Arrays.
-So first you need to search for the number '1' in 2D array (There are many solutions available if you do search for Search 2D array).
-Then once you get indices you can find mean by using this : http://zone.ni.com/reference/en-XX/help/371361M-01/gmath/mean/
08-02-2016 05:11 AM
the sample matrix is defined as
[0 0 0 0 0 0 0
0 0 0 0 1 1 0
0 0 0 1 1 1 1
0 0 0 1 1 1 1
0 0 0 1 1 1 1
0 0 0 0 1 1 0
0 0 0 0 0 1 0]
I want to find the mean of row and column of element which are 1.
for example the mean of this matrix by elemnts 1 is almost row=4, column=5
08-02-2016 05:50 AM
Can you explain how the mean for row is 4?
08-02-2016 09:15 AM
@andisheye20 wrote:the sample matrix is defined as
[0 0 0 0 0 0 0
0 0 0 0 1 1 0
0 0 0 1 1 1 1
0 0 0 1 1 1 1
0 0 0 1 1 1 1
0 0 0 0 1 1 0
0 0 0 0 0 1 0]
I want to find the mean of row and column of element which are 1.
for example the mean of this matrix by elemnts 1 is almost row=4, column=5
Your usage of the word 'mean' is confusing. Do you mean:
1. The centre of mass of the elements that are '1'? Because the coordinates for the middle of the cluster of 1's appear to be approximately [4,5].
2. The mathematical mean of the values, the same as the average value? This would result in seven row means and seven column means, all values somewhere fractionally between 0 and 1.
3. The 'average' of all x indices and y indices for where elements '1' are located? For example, there are 1's at locations [1,4], [1,5], [2,3], [2,4], [2,5], [2,6], [3,3], [3,4] etc. The means of these indices might be something like the centre of mass mentioned in point 1.
If you could be clearer on what you are trying to calculate?
08-02-2016 09:35 AM
hello
I had write the way to achieve the answer for rows
the answer for the column is like the row
the attachment has the writen solution
thanks alot
08-02-2016 09:40 AM
excuseme I want the centre of mass of the elements that are '1'.
but i can not .
would you please help me to write the code.
08-02-2016 10:06 AM
-Used search 2d array to get the indices and incremented by 1, beacuse array indices starts with 0.
-Indexed Array to get all rows and coulmns separately and then sent to Mean VI.
08-02-2016 10:15 AM
sorry sir
you have saved the file in labview15
but my lab is for 2014
would you please save it for labview 2014