How to make a function defined at discrete points?

 Akzeptierte Antwort

Star Strider
Star Strider am 12 Sep. 2016
One possibility:
xn = @(n) [(n==0) (n==1) (n==2) (n==5) (n==6)]*[1; 2; 3; 2; 2];
y = xn(2)
y =
3

Weitere Antworten (0)

Kategorien

Mehr zu Interactions, Camera Views, and Lighting finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by