フィルターのクリア

Help with If else statement

2 ビュー (過去 30 日間)
Konstantina Vaitsi
Konstantina Vaitsi 2020 年 5 月 12 日
コメント済み: Konstantina Vaitsi 2020 年 5 月 12 日
I have a series of x numbers and I want to create a script where "if x<5 then y = 50-0.5*x else y = 50+0.5*x and y = 0 if 50-0.5*x<0". How can I write this in octave/matlab?

採用された回答

KSSV
KSSV 2020 年 5 月 12 日
y = zeros(size(x)) ;
y(x<5) = 50-0.5*x(x<5) ;
y(x>=5) = 50+0.5*x(x>=5) ;
  1 件のコメント
Konstantina Vaitsi
Konstantina Vaitsi 2020 年 5 月 12 日
Oh my god, it was that easy? Thank you so much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssembly についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by