creating a function with a condition set
이전 댓글 표시
How do I create this function in Matlab? All of the tutorials seem to use very simple syntax in the functions.
f(t) = {
댓글 수: 3
Hollie Pietsch
2017년 9월 16일
Walter Roberson
2017년 9월 16일
Perhaps post an image of the formula.
Hollie Pietsch
2017년 9월 16일
답변 (1개)
Walter Roberson
2017년 9월 16일
편집: Walter Roberson
2017년 9월 16일
Otherwise, you need something like
function ft = f(t)
ft = nan(size(t));
mask = t >= 0 & t < 2;
ft(mask) = t(mask) - 1;
mask = t >= 2 & t < 4;
ft(mask) = 3 - t(mask);
Notice the nan: your function definition does not define any value for t outside of [0, 4) so no number can be assigned for those cases.
카테고리
도움말 센터 및 File Exchange에서 Vehicle Scenarios에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
