How can I apply a condition on a culumn?

1 次查看(过去 30 天)
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 ?

回答(2 个)

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

请先登录,再进行评论。


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

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by