필터 지우기
필터 지우기

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 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