nested if or piecewise function
2 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/268080/image.png)
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
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
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 Center 和 File 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!