lambda function with if statement
93 ビュー (過去 30 日間)
古いコメントを表示
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)
0 件のコメント
回答 (3 件)
Erivelton Gualter
2019 年 5 月 6 日
You can use the following line of code:
X = @(om) (1*(abs(om)==1) + 0*(abs(om)~=1));
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!