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
2019 年 5 月 6 日
2 投票
You can use the following line of code:
X = @(om) (1*(abs(om)==1) + 0*(abs(om)~=1));
NIMMALA HARATHI
2020 年 5 月 23 日
0 投票
[X, lambda] = eig(A)
saideh zare
2021 年 7 月 4 日
0 投票
Unrecognized function or variable 'lambda'.
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!