フィルターのクリア

How do i calculate for conditions

2 ビュー (過去 30 日間)
Rahah Hadri
Rahah Hadri 2021 年 3 月 3 日
コメント済み: Rahah Hadri 2021 年 3 月 30 日
Hi,
I am trying to calculate actual evapotranspiration(AE) from my data. the conditions and calculation are as follows:
if P - PET > 0
AE = PET
elseif P - PET < 0
AE = P - SMdiff
P, PET and SMdiff are all 12 x 1 double.
How do i compute this in matlab?
  1 件のコメント
darova
darova 2021 年 3 月 3 日
What about for loop?

サインインしてコメントする。

採用された回答

Drishan Poovaya
Drishan Poovaya 2021 年 3 月 25 日
I understand that you want code to calculate these conditions. I assume you are looking for a vectorized approach rather than a for loop. The code below should perform your calculations
AE = P>PET %logical 12 x 1 array
AE = AE.*PET + (~AE).*(P-SMdiff)
  1 件のコメント
Rahah Hadri
Rahah Hadri 2021 年 3 月 30 日
Thank you so much! This did exactly what I wanted.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by