lambda function with if statement

조회 수: 193 (최근 30일)
ion sme
ion sme 2019년 5월 6일
답변: saideh zare 2021년 7월 4일
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일
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일
[X, lambda] = eig(A)

saideh zare
saideh zare 2021년 7월 4일
Unrecognized function or variable 'lambda'.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by