MATLAB
MATLAB
% 2x+3y+4z=1
% 4x+5y+ z=2
% 5x+6y+7z=3
clc;clear all;close all;
syms x1 x2 x3
eq1 = 2*x1 +3*x2 +4*x3-1;
eq2 = 4*x1 +5*x2+x3-2;
eq3 = 5*x1+6*x2+7*x3-3;
sol = solve(eq1,eq2,eq3);
double(sol.x1)
double(sol.x2)
double(sol.x3)
%
OUTPUT
% x=
% 1.0667
% y=
% -0.4667
% z=
% 0.0667
OUTPUT
% Q3 : Write a matlab script file to generate & plot a sequence c*u(-n-n0) where c=2 ,n0=3
clc;
close all;
clear all;
n=-10:1:10;
u=stepfun(n,3);
u_n=fliplr(u);
f=2*u_n;
stem(n,f);
xlabel('n');
ylabel('y');
title('y=2u(-n-3)');
OUTPUT
OUTPUT
y(t) at t=1 is
0.3729
% Q6 : Write a program that plots the frequency response of a first order system
% H(z)=1/(1-0.8z^-1)
a=[1];% numerator co-efficient
b=[1 -.8];% denominator co-efficient
freqz(b,a);%plot response
OUTPUT
%Q7 For 0<=n<=10,plot the following discrete time signals in a single window
% unit step,exponential,sinusoidal,unit impulse
%Unit Step
clc;clear all;close all;
N=10;
x1=ones(1,N);
n=0:1:N-1;
subplot(2,2,1),stem(n,x1);
title('Unit Step Sequence');
%Exponenetial
x2=.6.^(n);
subplot(2,2,2);
stem(n,x2);
Title('Exponential');
%Sinusoidal
x3=.2*cos(.3*pi*n);
subplot(2,2,3),stem(n,x3);
title('Sinusoidal');
%Unit Impulse
x4=ones(1,1);
subplot(2,2,4),stem(x4);
Title('Unit Impulse');
OUTPUT
% Q10 :Design a 1024 tapped FIR filter with cutoff frequency of pi/2 and
% plot the requency response
clc;
close all;
clear all;
b = 0.5*sinc(0.5*(-512:512));
b = b.*hamming(1025)';
fvtool(b,1);
OUTPUT
% Q15 : Create two figures of y1=e^x and y2=e^-x in the same graph for the same
%
values of x;
clc;
close all;
clear all;
t=-10:0.1:10;
y1=exp(t);
y2=exp(-t);
plot(t,y1,t,y2);
xlabel('x');
OUTPUT