Effacer les filtres
Effacer les filtres

How to select one of the array and change the array data selected with another value ?

1 vue (au cours des 30 derniers jours)
example :
datasample [83 84 82 81 82 86 81 85 87 *88*];
if datasample > 87
datasample = mean(datasample);
end
I want change the biggest value in datasample that is 88 with mean ( 83)
how to code like that ?

Réponse acceptée

David Fletcher
David Fletcher le 19 Mar 2018
Modifié(e) : David Fletcher le 19 Mar 2018
datasample=[83 84 82 81 82 86 81 85 87 88];
datasample(datasample==88) = mean(datasample);
or more generally
datasample(datasample==max(datasample)) = mean(datasample)

Plus de réponses (2)

Birdman
Birdman le 19 Mar 2018
Modifié(e) : Birdman le 19 Mar 2018
[~,idx]=max(datasample);
datasample(idx)=mean(datasample)

Muhammad Hafiz
Muhammad Hafiz le 19 Mar 2018
Thank you for answer my question, both of you answer the correctly :)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by