nested if or piecewise function

조회 수: 2 (최근 30일)
liyana nadirah
liyana nadirah 2020년 1월 24일
댓글: Mohammad Sami 2020년 1월 26일
can someone explain to me how to do matlab coding for this piecewise function. did i have to do nested if coding to solve this function
  댓글 수: 2
tilman knebel
tilman knebel 2020년 1월 24일
The fastest way is, to evaluate it for all required t at once: create the target array with "zeros" and fill in the solution for each of both partitions.
Mohammad Sami
Mohammad Sami 2020년 1월 26일
You can use a switch statement
switch true
case t <= t_prime
out = 0
case t <= Y && t > t_prime
out = 3 % rest of your expression;
otherwise
out = 1 % rest of your expression;
end

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by