lambda function with if statement

192 次查看(过去 30 天)
ion sme
ion sme 2019-5-6
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
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