Effacer les filtres
Effacer les filtres

Specifying a range in a double

5 vues (au cours des 30 derniers jours)
Keith Grey
Keith Grey le 15 Mai 2020
Commenté : Keith Grey le 15 Mai 2020
% 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 commentaire
Fangjun Jiang
Fangjun Jiang le 15 Mai 2020
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?

Connectez-vous pour commenter.

Réponse acceptée

William Alberg
William Alberg le 15 Mai 2020
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 commentaire
Keith Grey
Keith Grey le 15 Mai 2020
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!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by