How can I apply a condition on a culumn?

1 回表示 (過去 30 日間)
Hamed Hedayatnia
Hamed Hedayatnia 2020 年 9 月 18 日
回答済み: madhan ravi 2020 年 9 月 18 日
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 Center および File ExchangeLogical についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by