lambda function with if statement

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)

답변 (3개)

Erivelton Gualter
Erivelton Gualter 2019년 5월 6일

2 개 추천

You can use the following line of code:
X = @(om) (1*(abs(om)==1) + 0*(abs(om)~=1));
NIMMALA HARATHI
NIMMALA HARATHI 2020년 5월 23일

0 개 추천

[X, lambda] = eig(A)
saideh zare
saideh zare 2021년 7월 4일

0 개 추천

Unrecognized function or variable 'lambda'.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2019a

질문:

2019년 5월 6일

답변:

2021년 7월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by