How to make a function defined at discrete points?

 Accepted Answer

One possibility:
xn = @(n) [(n==0) (n==1) (n==2) (n==5) (n==6)]*[1; 2; 3; 2; 2];
y = xn(2)
y =
3

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!