lambda function with if statement

198 ビュー (過去 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 Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by