Matlab 으로 DSP 실습시간에 만든것

2007. 7. 4. 14:45Work/Robot

무척 간단하다.

% -------------------- M File Start --------------------
% Impulse Function
% n0, n1, n2

function [x,n] = impseq(n0,n1,n2)

n = [n1:n2];
x = [(n-n0) == 0];

% -------------------- M File End --------------------


% -------------------- M File Start --------------------
% Step FUnction
% n0, n1, n2
% n(from n1 to n2), compare with n0
% if n0


function [x,n] = stepseq(n0,n1,n2)

n = [n1:n2];
x = [(n-n0) >= 0];
% -------------------- M File End --------------------



---------- 기타 다음과 같은 명령어 실습 ----------
n=[0:20];
x1 = n.*(stepseq(0,0,20)-stepseq(10,0,20));
x2 = 10*exp(-0.3*(n-10).*(stepseq(10,0,20)-stepseq(20,0,20)));
x=x1+x2;


%% plot / Graph Command
th=0:0.5:2*pi
x=sin(th)+i*cos(th);
subplot(2,2,4):stem(phase(x));
subplot(2,2,3):stem(abs(x));
subplot(2,2,2):stem(imag(x));
subplot(2,2,1):stem(real(x));

사용자 삽입 이미지



x=[0 0 0 1 0 0 0];
h=[1 2 3 4 5 6 7];
y=conv(x,h);