How can I apply a condition on a culumn?

1 visualización (últimos 30 días)
Hamed Hedayatnia
Hamed Hedayatnia el 18 de Sept. de 2020
Respondida: madhan ravi el 18 de Sept. de 2020
Hi,
I want to apply this condition on TT_wind_all_mashhad.wind_dir_remo.
if (value > 360) then (value-360) & if (value < 0) then (value + 360)
How can I do it ?

Respuestas (2)

KSSV
KSSV el 18 de Sept. de 2020
Editada: KSSV el 18 de Sept. de 2020
Let A be your array.
idx = A>360 ;
A(idx) = A(idx)-360 ;
idx = A<360 ;
A(idx) = A(idx)+360 ;
  2 comentarios
Hamed Hedayatnia
Hamed Hedayatnia el 18 de Sept. de 2020
something is wrong, I applied it getting no error but no changes applied on my array
KSSV
KSSV el 18 de Sept. de 2020
Before and after applying check the values with indices idx.

Iniciar sesión para comentar.


madhan ravi
madhan ravi el 18 de Sept. de 2020
A = (A - 360) .* (A > 360) + (A + 360) .* (A < 0) + A .* ((A >= 0) & (A <= 360));

Categorías

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

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by