lambda function with if statement
198 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (3)
Erivelton Gualter
am 6 Mai 2019
You can use the following line of code:
X = @(om) (1*(abs(om)==1) + 0*(abs(om)~=1));
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!