lambda function with if statement
조회 수: 193 (최근 30일)
이전 댓글 표시
How do I make the following function work for X. I want to be able to write lambda functions with an if clause.
X = @(om) (if abs(om)<1; 1; else 0; end)
댓글 수: 0
답변 (3개)
Erivelton Gualter
2019년 5월 6일
You can use the following line of code:
X = @(om) (1*(abs(om)==1) + 0*(abs(om)~=1));
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!