Wednesday, February 6, 2013

Using inline function to plot discrete functions

Enter the following code in the matlab command window....
n = -3.5 : 0.1 : 3.5;
f = inline('(-1.5*n).*((n>=-3)&(n<-1)) + ((n>=-1)&(n<1)) + (.5*n+1).*((n>=1)&(n<=3))', 'n');
stem(f(n))



Now try each of the following:
stem(n,f(n),'*-')
stem(n,f(n),'--')

No comments:

Post a Comment