Find position

5 次查看(过去 30 天)
Paul
Paul 2011-12-23
How can I find from an input vector the position of the number that deviates the most from the average of the values of the vector.

回答(2 个)

Image Analyst
Image Analyst 2011-12-23
averageOfVector = mean(vector);
Now, assuming the input vector, inputVector, has positions in it, what do those positions deviate FROM by more than averageOfVector? Is there a third vector, like
deviations = inputVector - thirdVector;
firstPosition = find(deviations > averageOfVector , 1, 'First');
  2 个评论
Paul
Paul 2011-12-23
I think i need to use mean to find the average and then compare it with all the values and show the position of the value that deviates the most from that average, it can be negative but also positive.
Image Analyst
Image Analyst 2011-12-23
Sounds like a class assignment. Hint: use the max() function and look at both return arguments. Also look at the abs() function.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2011-12-23
You want to know the location of the MAXimum ABSolute difference between x and its MEAN ?

类别

Help CenterFile Exchange 中查找有关 NaNs 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by