% Values is a 401x1 double: 1 - 401
% In this example, I want to take the mean from Values(90) to Values(110).
% Specify Bounds
MAX = 90; %
MIN = 110;
idy = find(Values == MIN);
idz = find(Values == MAX);
Values = mean(Values(idy:idz));
This is simple & should be returning 1 number from Values after taking the mean, but it's resulting in a 1x7^6 double.
Is there a syntax error that I'm overlooking here?

댓글 수: 1

Fangjun Jiang
Fangjun Jiang 2020년 5월 15일
code is simple enough. run the code line by line and see where is wrong.
The numerical value for MAX and MIN seems to be reversed. Is that correct?

댓글을 달려면 로그인하십시오.

 채택된 답변

William Alberg
William Alberg 2020년 5월 15일

0 개 추천

I think, that you want to do this:
MAX = 110;
MIN = 90;
id = find( (MIN <= Values) & (Values <= MAX) )
Values = mean(Values(id))
I switched the MIN/MAX values

댓글 수: 1

Keith Grey
Keith Grey 2020년 5월 15일
Ah, I see what I did now! The MAX value was lower than the MIN, so of course the computer's going to hate that. Thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2017b

질문:

2020년 5월 15일

댓글:

2020년 5월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by