lambda function with if statement

189 vues (au cours des 30 derniers jours)
ion sme
ion sme le 6 Mai 2019
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)

Réponses (3)

Erivelton Gualter
Erivelton Gualter le 6 Mai 2019
You can use the following line of code:
X = @(om) (1*(abs(om)==1) + 0*(abs(om)~=1));

NIMMALA HARATHI
NIMMALA HARATHI le 23 Mai 2020
[X, lambda] = eig(A)

saideh zare
saideh zare le 4 Juil 2021
Unrecognized function or variable 'lambda'.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by