0 Comments
sequence=input('Insert the sequence : ');
lengthdft=input('Insert the length of the DFT : '); l=length(sequence); if lengthdft >l sequence =[ sequence zeros(1, lengthdft -l)]; elseif lengthdft <l sequence = sequence (1: lengthdft); end i=sqrt(-1); fx=exp(-i*2*pi/ lengthdft); n=0:( lengthdft -1); k=0:( lengthdft -1); nk=n'*k; W=fx.^nk; X= sequence *W; disp(X); subplot(2,1,1); stem(k,abs(X)); title('Spectrum showing magnitude'); xlabel('Discrete frequency'); ylabel('Amplitude'); grid; subplot(2,1,2); stem(k,angle(X)); title('Spectrum showing phase'); xlabel('Discrete frequency'); ylabel('Phase Angle'); grid; Convolution of two fourier transformed signals is equal to the fourier transform of two multiplied signals. Below is the matlab verification.
function [ w ] = convmat( x1,x2 ) n=0:100; x1=[1 2 3 4 5]; x2=[6 7 8 9 10]; lengthofx1=length(x1); lengthofx2=length(x2); X1=[x1,zeros(1,lengthofx2)]; X2=[x2,zeros(1,lengthofx1)]; for k=1:(lengthofx1+lengthofx2-1) w(k)=0; for j=1:lengthofx1 if(k-j+1)>0 w(k)=w(k)+X1(j)*X2(k-j+1); end end end subplot(3,2,1) r=x1.*x2; f=abs(fft(r)); stem(f) title('fourier transform of two multiplied signals') subplot(3,2,2) a1=abs(fft(x1)); a2=abs(fft(x2)); b=conv(a1,a2); stem(b) title('convolution of two fourier transformed signals') end Fourier transform of two multiplied signals is equal to the multiplication of two fourier tranformed signals. Below is the matlab verification code.
Code: clear all; clc x1=[1 2 3 4 5]; x2= [6 7 8]; lengthofx1= length(x1); lengthofx2= length(x2); m=max(lengthofx1,lengthofx2); x1=[x1 zeros(1,m-lengthofx1)]; x2=[x2 zeros(1,m-lengthofx2)]; for n=0:m-1; y(n+1)=0; for i=0:m-1 j=mod(n-i,m); y(n+1)=y(n+1)+x1(i+1)*x2(j+1); end end n=0:1:4; X1=fft(x1); X2=fft(x2); Y=fft(y); subplot(2,1,1) stem(n,Y); title('fourier transform of two multiplied signals') xlabel('time(t)') ylabel('Amplitude') Y1=(X1).*(X2); subplot(2,1,2); stem(n,Y1); title('multiplication of two fourier tranformed signals'); xlabel('time(t)'); ylabel('Amplitude') Result: fs=8192;
ts=1/fs; time= 0:ts:1 for k=2:1:8 f1=392; tone=tone+(0.25.^(k-1)).*sin(2*pi*k*f1*time); end soundsc(tone) stem(time,tone) function [ w ] = convmat( x,h )
for s=1:10 x(s)=1 end for g=1:5 h(g)=0.2; end lengthofx=length(x); lengthofh=length(h); X=[x,zeros(1,lengthofh)]; H=[h,zeros(1,lengthofx)]; for k=1:(lengthofx+lengthofh-1) w(k)=0; for j=1:lengthofx if(k-j+1)>0 w(k)=w(k)+X(j)*H(k-j+1); end end end sum=0; for l=1:length(w) sum=sum+w(l); end sum subplot(1,2,1) stem(w) title('By using convmat') y=conv(x,h) subplot(1,2,2) stem(y) title('By using conv command') end Matlab Code:
n=-10:20; u1=(n>=0); u2=(n>=6); d1=(n==1); d2=(n==2); d3=(n==3); x1=sin(0.12*pi*n); x2=u1-u2; x3=0.9.^n.*u1; x4=0.5*d1+d2+0.5*d3; x5=0.9.^n.*cos(0.2*pi*n); x6=sin(0.2*pi*n)./(0.2*pi*n); subplot(2,3,1) stem(n,x1) xlabel('discret values (n)'); ylabel('sin function'); title('signal generation in matlab'); subplot(2,3,2) stem(n,x2) xlabel('discret values (n)'); ylabel('The difference function'); title('signal generation in matlab'); subplot(2,3,3) stem(n,x3) xlabel('discret values (n)'); ylabel('decreaing function'); title('signal generation in matlab'); subplot(2,3,4) stem(n,x4) xlabel('discret values (n)'); ylabel('sigma or delta function'); title('signal generation in matlab'); subplot(2,3,5) stem(n,x5) xlabel('discret values (n)'); ylabel('decreasing cosine function'); title('signal generation in matlab'); subplot(2,3,6) stem(n,x6) xlabel('discret values (n)'); ylabel('sin function with fluctuations'); title('signal generation in matlab'); Result: Matlab Code:
>> t=0:0.002:0.04; >> y=sin(2*pi*50*t); >> plot(t,y) >> hold on >> t1=0.01:0.002:0.05; >> y1=sin(2*pi*50*t); >> plot(t1,y1) >> t2=0.035:0.002:0.075; >> y2=sin(2*pi*50*t); >> plot(t2,y2) >> grid; >> xlabel('time(s)'); >> ylabel('amplitude'); >> title('three phase sine wave'); Final Result: |
Categories
All
Archives
March 2014
This section will not be visible in live published website. Below are your current blog design settings: Current Number Of Columns are = 1 Blog Post Style = card Use of custom card colors instead of default colors = Blog Post Card Background Color = current color Blog Post Card Shadow Color = current color Blog Post Card Border Color = current color Use of custom colors instead of theme colors for below options= Blog Post Title Color = current color Blog Post Title Hover Color = current color Blog Post Date Color = current color Blog Post Date Hover Color = current color Blog Post Read More Link Color = current color Blog Post Read More Link Hover Color = current color Blog Post Comments Count Color = current color Blog Post Comments Count Hover Color = current color |