n=(0:15);
x=.^n;
figure(1);
subplot(2,2,1);
stem(n,x);
xlabel('n');
ylabel('x');
grid on;
y=exp((+j*3)*n);
figure(1);
subplot(2,2,2);
stem(n,y);
xlabel('n');
ylabel('y');
grid on;
x=3*cos(*pi*n+*pi)+2*sin(*pi*n+*pi);
figure(1);
subplot(2,2,3)
stem(n,x);
xlabel('n');
ylabel('x');
grid on;
function nn=stepshift(n0,n1,n2)
n11=n1+n0;
n22=n2+n0;
nn=n11:n22;
n=0:9;
n1=0;n2=9;n0=2;
x=ones(1,10);
figure(1);
subplot(2,2,1);
grid on;
y=stepshift(n0,n1,n2);
stem(n,x);
xlabel('n');
ylabel('x');
subplot(2,2,2);
stem(y,x);
xlabel('y');
ylabel('x');
grid on;
x=[1 -1 3 5];
n0=[0:3];
n1=[-2:1];
n2=[1:4];
n=[min(min(n1),min(n2)):max(max(n1),max(n2))];
y1=zeros(1,length(n));
y0=y1;
y2=y1;
y1(find((n>=min(n1)&n<=max(n1))==1))=x
y0(find((n>=min(n0)&n<=max(n0))==1))=x
y2(find((n>=min(n2)&n<=max(n2))==1))=x
y=y1+y2+y0;
figure(1);
stem(n,y);
xlabel('n');
ylabel('y');
grid on
n=[0:3];
A=[1 2 3 4];
B=[3 4 5 6];
C=A+B;
D=A-B;
E=A.*B
F=A./B;
G=A.^B;
figure(1);
subplot(2,2,1);
stem(n,A);
xlabel('n');
ylabel('A');
title('序列的运算');
grid on;
subplot(2,2,2);
stem(n
matbal程序 来自淘豆网www.taodocs.com转载请标明出处.