Finding max, min or avg value of a section of vector

33 views (last 30 days)
I have a vector of size 35116x1. I want to find max, min or avg of only a section of the vector like only using the first 2926 elements. I tried using index but it doesn't work. Am I doing anything wrong here or is there any other way of doing it?
for i=1:2926
max(num2(i,1)) %num2 is the vector
end
  2 Comments
Claudio Stucki
Claudio Stucki on 5 Feb 2017
if your vector num2 includes the first 2926 elements:
max(num2);
min(num2);
mean(num2);
Otherwise use you can use:
max(yourVector(1:2926))

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 5 Feb 2017
subset = num2(1:2926);
max(subset)
min(subset)
mean(subset)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!