How to define function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Viktoriia Buliuk
il 11 Ago 2020
Commentato: Viktoriia Buliuk
il 4 Set 2020
Hello!
Could you, please, suggest an answer:
How to define function f (x), which for x from -1 to 1, f (x) = 1; and outside these limits f (x) = 0.
Thank in advance!
3 Commenti
Risposta accettata
hosein Javan
il 11 Ago 2020
function y = f(x)
y = zeros(size(x));
y(abs(x) < 1) = 1;
end
5 Commenti
hosein Javan
il 11 Ago 2020
ofcourse unless you want to use function file, you need this multiplication only to define your function in anonymous form. correct.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Operators and Elementary Operations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!