MATLAB
- aryanrchoudhary
- Aug 12, 2020
- 1 min read
Digital Communication:

Signal Processing:
x=[1,5,2,4,2]
y=[3,7]
cl=conv(x,y)
stem(cl,'filled')
ylim=[0 40]
title('Convolution of x and y')
x=randn(6,1);
y=randn(6,1);
A=[x y 2*y+3];
R=corrcoef(A);
y1=fliplr(y)
cl1=conv(x,y1)
stem(cl1,'filled')
ylim=[0 40]
title('Correlation of x and y')
n=0:15;
xn=0.84.^n;
yn=circshift(xn,5)+0.3*randn;
[c,lags]=xcorr(xn,yn);
figure
subplot(2,1,1)
stem(lags,c)
title('Crosscorrelation of x and y')
%%%% Convolution of a rectangular pulse with itself
clc;
clear all;
close all;
x=ones(1,11);%%%%%rectangular pulse sequence
h=ones(1,11);%%%%
nx=[-5:5]; %%%%%(x axis -5 to 5)
LEx=nx(1); %%%%%Left end of x
nh=[-5:5];
LEh=nh(1);
Nx=length(x); %%%%Length of first sequence)
REx=nx(Nx); %%% Right end of x
Nh=length(h); %%%%Length of second sequence)
REh=nh(Nh); %%%Right end ofh
Ny=Nx+Nh-1; %%% Length of output
LEy=LEx+LEh; %%%%%LEft end of output
REy=REx+REh; %%%%Right end of output
ny=LEy:REy; %%%%%Variable for y vector
Xn=[x zeros(1,Nh-1)];
hn=[h zeros(1,Nx-1)];
for i=0:Ny-1
sum=0;
for j=0:i
sum=sum+Xn(j+1)*hn(i-j+1) %%%%Formula for Convolution
end
Y(i+1)=sum;
end
figure,
subplot(1,2,1),stem(nx,x);
subplot(1,2,2),stem(ny,Y);
y=conv(x,h);
ny=-10:1:10
figure, stem(ny,y)






Robotics:



Comments