Matrix Manipulation Average of specific column

I have data in excel that is 17 columns by 4800 rows. I need to find all the numbers in each column separately that are greater then 10 and then find there average. This needs to be done for each 17 columns. Just unsure how to do this. Thank You!

Answers (1)

If A is the array with your values, then
A10 = (A > 10);
meanA = sum(A.*A10)./sum(A10)

5 Comments

Just to be sure I understand, is the A10 referring to the tenth column? How do I find the numbers greater than ten in say the third column. Thank you so much for your input.
Did you actually try the code? It finds the means of all columns at once. A10 is a logical variable that is true for each element of A that is greater than 10, and false if it is not. meanA is a 17-element vector of the means.
Sorry I am a slow learner, this worked perfectly. I really like your style and was wondering if I could ask you another question.
So it is dealing with the same data I need to take the data from column F and H and find where each of them is greater than 10 in the same row. and then sore this information in a variable.
So say I have the 17 columns, I want the 6th column and the 8th column. Once I call those out, I want to find where they each are greater than 10. Once I know where they are greater 10, I need to know where the each are greater then ten. Like row 2000 F and H are greater then ten. Once I have the total number that is greater then ten in the same row I then will store them in a variable. Thank You so much.
I don't quite follow your explanation.
I suggest you ...
  • open up a new question
  • give a very small illustrative example (e.g. maybe just 4x3) what the input matrix looks like
  • explain what you expect for the output, and why
It's helpful if you define the input matrix in actual MATLAB code, and not just explain what it is like.
say I have an array A A=[10 20 3 5 6 4 7 10] We can see that the first and last columns both contain a number that is greater than or equal to 10. I need to know what row that happens in. Here it is easy because there is only one row, but I am dealing with 4800 rows. So I need to find the specific rows where the 6th column and the 8th column both are greater or equal to ten with in the same row. row 189 6th column=11 row 189 8th column=13 therefore row 189 would be a row I need to note. I need to find every row where this is true.

Sign in to comment.

Products

Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!