Depth Averaged Velocities - Nanmean higher than excluded values?!

Hello! I am trying to get depth averaged velocities for a time series and have excluded values greater than and less than 1 and -1 in order to get accurate data. I have then taken the nanmean but my velocities are all higher (or lower) than the range I have kept. I'm really not sure what I'm doing wrong here! My code is:
u = ConVel/1000;
a = find(u>=1 & u<=-1);
u(a) = NaN;
u_av = nanmean(u);
But the vector I am left with has values <-4? Thank you for your help!

 Respuesta aceptada

Steven Lord
Steven Lord el 13 de Jul. de 2018
Can you give me an example of a number that is simultaneously greater than or equal to 1 and less than or equal to -1?
You want to use the or operator | instead of the and operator &.

Más respuestas (0)

Etiquetas

Preguntada:

el 13 de Jul. de 2018

Comentada:

el 13 de Jul. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by