Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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 ?

Respuesta aceptada

David Fletcher
David Fletcher el 19 de Mzo. de 2018
Editada: David Fletcher el 19 de Mzo. de 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)

Más respuestas (2)

Birdman
Birdman el 19 de Mzo. de 2018
Editada: Birdman el 19 de Mzo. de 2018
[~,idx]=max(datasample);
datasample(idx)=mean(datasample)

Muhammad Hafiz
Muhammad Hafiz el 19 de Mzo. de 2018
Thank you for answer my question, both of you answer the correctly :)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by