필터 지우기
필터 지우기

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 CenterFile Exchange에서 Assembly에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by