Академический Документы
Профессиональный Документы
Культура Документы
syms t;
x=exp(-t);
y=x*cos(10*t);
subplot(4,2,1);ezplot(x,[0,5]);
axis([0 5 0 1.1]);title('x(t)');
subplot(4,2,2);ezplot(y,[-1,5]);
X=laplace(x)
Y=laplace(y)
Xm=abs(X);
Ym=abs(Y);
subplot(4,2,3);ezplot(Xm);
subplot(4,2,4);ezplot(Ym);
[r,p,k]=residue(num,den);
disp(r);
disp(p);
[11]
[221]
%%%%phase response
syms t w;
x=exp(-2*t).*heaviside(t);
subplot(3,1,1);ezplot(x);
title('x(t)=e^-2t');
X=fourier(x)
X=simplify(X);
subplot(3,1,2);ezplot(abs(X));
subplot(3,1,3);ezplot(atan(imag(X)/real(X)));
n=0:1:10
x=ones(1,length(n));
subplot(3,1,1);
stem(n,x);
title('step input');
num=[0 1 2];
den=[1 -1 2];
y=filter(num,den,x);
subplot(3,1,2);stem(y);
title('step response using matlab commmand')
y=(4/3)*(2).^n+(1/6)*(-1).^n-(3/2);
subplot(3,1,3);
stem(y);
%%%%%impulse response
syms n z
num=[1 2];
den=[1 -3 -4];
%transfer function
h=tf('z')
Ts=[];
H=tf(num,den,Ts)
[h,n]=impz(num,den)
subplot(2,1,1);stem(n,h);
ha=1.2*4.^n-0.2*(-1).^n;
subplot(2,1,2);
stem(n,ha)
n=-4:1:4;
k=-4:4;
w=(pi)*k;
X=x*(exp(-1j*pi/100)).^(n'*k);
subplot(3,1,1);stem(n,x);
Xm=abs(x);
subplot(3,1,2);
plot(w/pi,Xm);
xlabel('Frequency in pi units');ylabel('Phase');
Xp=phase(X);
subplot(3,1,3);plot(w/pi,Xp);
xlabel('Frequency in pi units');ylabel('Magnitude');
n=0:1:100;
x=cos(pi*n/4);
k=-300:300;
w=(pi/100)*k;
X=x*(exp(-j*pi/100)).^(n'*k);
subplot(3,1,1);stem(n,x);
title('sinosodial input signal');
Xm=abs(X);
subplot(3,1,2);plot(w/pi,Xm);
axis([-3 3 0 60]);
Xp=phase(X);
subplot(3,1,3);plot(w/pi,Xp);
% Write a MATLAB program to find the poles and the residues and pole-zero plot of a given system
function
disp('X(z)=z^3/((z-0.5)(z-0.75)(z-1))');
syms z;
zer = -0.5;
d=(z-0.5)*(z-0.75)*(z-1);
a1=collect(d);
den=sym2poly(a1);
n=z^3;
a2=collect(n);
num=sym2poly(a2);
[r p k]=residue(num,den);
fprintf('r1=%4.2f\t',num(1));
fprintf('p1=%4.2f\n',den(1));
fprintf('r2=%4.2f\t',num(2));
fprintf('p2=%4.2f\n',den(2));
fprintf('r3=%4.2f\t',num(3));
fprintf('p3=%4.2f\n',den(3));
zplane(zer,pol);
t=0.2;
H=tf('z');
H=tf(num,den,t);
% Fourier Transform
syms t w;
x=2*(heaviside(t+2)-heaviside(t-2));
subplot(2,1,1);ezplot(x,[-2 2]);
X=int(x*exp(-1i*w*t),t,-5,5);
X=simplify(X);
disp(X);
subplot(2,1,2);ezplot(X);
%ztransform
%%%z transform
syms n w;
x1=n+1;
disp('The input signal is');
disp(x1);
X1=ztrans(x1);
disp(X1);
X11=iztrans(X1);
disp(X11);
x2=sin(n*w);
disp(x2);
X2=ztrans(x2);
disp(X2);
X22=iztrans(X2);
disp(X22);
%%%time scaling
subplot (3 ,1 ,1)
subplot (3 ,1 ,3)
%%%%time shifting
subplot (3 ,1 ,1)
subplot (3 ,1 ,2)
subplot (3 ,1 ,3)
%%%amplitude scaling
a=256; % FFT Length
t=0:1/a:(a-1)/a;
s=(sin(2*pi*12*t)+.8*j*sin(2*pi*4.25*t)+.01*randn(size(t)))/2;
subplot(211)
plot(t,real(s))
subplot(212)
plot(t,imag(s))