星期三, 12月 02, 2009

matlab 2009 12/03 w01


% program file w1_20091203.m
clear all;
close all;
x_n = [2 1 1/2 1/4];
nx = [-1 0 1 2];
h_n = [1 1 1 1 ];
nh = [0 1 2 3];
y_n = conv(x_n,h_n);
y_n2 = conv(h_n,x_n);

n0 = nx(1) + nh(1);
N = length(nx)+length(nh)-1;
n = n0:n0 + N-1;

subplot(211);
stem(n,y_n,'b');
grid;

subplot(212);
stem(n,y_n2,'r');
grid;

matlab 2009 12/03 w01


% program file w1_20091203.m
clear all;
close all;
n_x = [2 1 1/2 1/4];
nx = [-1 0 1 2];
h_n = [1 1 1 1 ];
nh = [0 1 2 3];
y_n = conv(n_x,h_n);

n0 = nx(1) + nh(1);
N = length(nx)+length(nh)-1;
n = n0:n0 + N-1;

subplot(111);
stem(n,y_n,'b');
grid;