Core llvm compile dsp

17 Ansichten (letzte 30 Tage)
Pochita
Pochita am 20 Nov. 2023
Kommentiert: Les Beckham am 20 Nov. 2023
AIM: Plotting the pole-zero plot, magnitude and phase spectrum and steadystate response of an LTI System
MATLAB Code: clc; close all; x=[1]; %Numerator of Transfer Function y=[1,-0.9]; %Denominator of Transfer Function subplot(3,1,1) zplane(x,y); %Pole-Zero Plot x=[1]; %Numerator of Transfer Function y=[1,-0.9]; %Denominator of Transfer Function w=linspace(-2*pi,2*pi); H=freqz(x,y,w); magH=abs(H); angH=angle(H); subplot(3,1,2); plot(w/pi,magH); xlabel('Frequency in pi'); ylabel('Magnitude'); title('Magnitude Response'); subplot(3,1,3); plot(w/pi,angH); xlabel('Frequency in Pi'); ylabel('Phase in Pi radians'); title('Phase Response'); x=[1]; %Numerator of Transfer Function y=[1,-0.9]; %Denominator of Transfer Function n=[0:150]; z=cos(0.05*pi*n); a=filter(x,y,z); figure,subplot(2,1,1); stem(n,z); xlabel('n'); ylabel('x[n]'); title('Input Signal'); subplot(2,1,2); stem(n,a); xlabel('n'); ylabel('y[n]'); title('Output Signal');xlabel('n');
AIM: Computing DTFT, 4, 8 and 16 point DFT of 4 point sequence. Verifying Circular time-shifting and circular time-reversal properties for a 9 point sequence
MATLAB Code: clc; close all; %DTFT w=0:0.01:2*pi; Xw=1+exp(-j*w)+exp(-j*2*w)+exp(-j*3*w); %4-point DTFT xn=ones(1,4); N=4; n=0:N-1; k=0:N-1; WN=exp(-j*2*pi/N*n'*k); Xk=xn*WN; subplot(221); plot(w,abs(Xw)); xlabel('Frequency'); ylabel('Magnitude'); title('DTFT'); subplot(222); plot(w,abs(Xw));hold on stem(2*pi*k/N,abs(Xk),'filled'); xlabel('2*pi*k/4'); ylabel('Magnitude'); title('4-point DTFT'); %8-point DTFT clear N; xn=[ones(1,4) zeros(1,4)]; N=8; n=0:N-1; k=0:N-1; WN=exp(-j*2*pi/N*n'*k); Xk=xn*WN; subplot(223); plot(w,abs(Xw));hold on stem(2*pi*k/N,abs(Xk),'filled'); xlabel('2*pi*k/8'); ylabel('Magnitude'); title('8-point DTFT'); %16-point DTFT clear N; xn=[ones(1,4) zeros(1,12)]; N=16; n=0:N-1; k=0:N-1; WN=exp(-j*2*pi/N*n'*k); Xk=xn*WN; subplot(224); plot(w,abs(Xw));hold on stem(2*pi*k/N,abs(Xk),'filled'); xlabel('2*pi*k/16'); ylabel('Magnitude'); title('16-point DTFT');
AIM: Computing 4-point circular convolution and computing linear convolution using fit.
MATLAB Code: (i) clc; close all; N=4; x1=[1 2 2 1]; x2=[1 -1 -1 1]; y=zeros(1,N); %circular convolution for n=0:N-1 m=0:N-1; n1=mod(n-m,N); xs2=x2(n1+1); x12=x1.*xs2; y(n+1)=sum(x12); end n=0:N-1; subplot(131); stem(n,x1,'filled'); xlabel('n'); title('x1(n)'); subplot(132); stem(n,x2,'filled'); xlabel('n'); title('x2(n)'); subplot(133); stem(n,y,'filled'); xlabel('n'); title('y(n)'); (ii) clc; close all; N=4; x1=[1 2 2 1]; Nx1=length(x1); x2=[1 -1 -1 1]; Nx2=length(x2); Ny=Nx1+Nx2-1; x1z=[x1 zeros(1,Ny-Nx1)]; x2z=[x2 zeros(1,Ny-Nx2)]; y=zeros(1,Ny); %circular convolution for n=0:Ny-1 m=0:Ny-1; n1=mod(n-m,Ny); x2s=x2z(n1+1); x12=x1z.*x2s; y(n+1)=sum(x12); end n=0:Ny-1; subplot(131); stem(n,x1z,'filled'); xlabel('n'); title('x1(n)'); subplot(132); stem(n,x2z,'filled'); xlabel('n'); title('x2(n)'); subplot(133); stem(n,y,'filled'); xlabel('n'); title('y(n)');
AIM: Computing LTI response of a system using overlap-add and overlap-save methods
MATLAB Code: (i) %Experiment 4(a) clc; close all; n=0:9; N=6; x=n+1; Lenx= length(x); h=[1 0 -1]; M=length(h); M1=M-1; L=N-M1; hz=[h zeros(1,N-M)]; %Appending N-M Zeros nhz=0:length(hz)-1; xz=[zeros(1,M1) x zeros(1,N-1)]; %Pre Appending M-1 Zeros nxz=0:length(xz)-1; K=ceil((Lenx+M1-1)/L); y=zeros(K,N); for i=0:K-1 xi=xz(i*L+1:i*L+N) for j=0:N-1 m=0:N-1; n1=mod(j-m,N); hs=hz(n1+1); xh=xi.*hs; y(i+1,j+1)=sum(xh); end end y=y(:,M:N)'; %DiscaRding First M-1 Samples y=[y(:)]'; %Concatenating The Output ny=0:length(y)-1; subplot(1,3,1); stem(nxz,xz,'filled'); xlabel('n'); ylabel('x(n)'); title('x(n)'); subplot(1,3,2); stem(nhz,hz,'filled'); xlabel('n'); ylabel('h(n)'); title('h(n)'); subplot(1,3,3); stem(ny,y,'filled'); xlabel('n'); ylabel('y(n)'); title('y(n)');
(ii) close all; clc; n=0:9; N=4; x=n+1; Lenx=length(x); h=[1 0 -1]; M=length(h); M1=M-1; L=N+M-1; hz=[h zeros(1,L-M)]; %Appending N-M Zeros nhz=0:length(hz)-1; K=ceil(Lenx/N); xx=[x zeros(1,N*K-Lenx)]; %Preappending M-1 Zeros nxx=0:length(xx)-1; y=zeros(K,N); for i=0:K-1 xi=xx(i*N+1:N*(i+1)); xr=[xi zeros(1,M1)]; for j=0:L-1 m=0:L-1; n1=mod(j-m,L); hs=hz(n1+1); xh=xr.*hs; y(i+1,j+1)=sum(xh); end end yy=[]; %Adding Last M-1 Samples for i=1:K-1; y(i,:)=[y(i,1:N) y(i,N+1:L)+y(i+1,1:M1)]; end yy=[y(1,1:L) y(2,M:L) y(3,M:L-M1)]; ny=0:length(yy)-1; subplot(1,3,1); stem(nxx,xx,'filled'); xlabel('n'); ylabel('x(n)'); title('x(n)'); subplot(1,3,2); stem(nhz,hz,'filled'); xlabel('n'); ylabel('h(n)'); title('h(n)'); subplot(1,3,3); stem(ny,yy,'filled'); xlabel('n'); ylabel('y(n)'); title('y(n)');
AIM: Computing 100 point DFT of a function with and without padding 90 zeroes
MATLAB Code: clc; close all; n=1:100; k=1:100; x=cos(0.48*pi*n)+cos(0.52*pi*n); %Input Signal xpad=[x(1:10),zeros(1,90)]; %Input Signal With Padded Zeros N=100; %N-point DFT w=2*pi/N; subplot(2,2,1); stem(x); title('Input Signal'); subplot(2,2,2); stem(abs(x*exp(-1i*(n'*w*k)))); title('100-Point DFT of Input Signal'); subplot(2,2,3); stem(xpad); title('Input Signal with Padded Zeros'); subplot(2,2,4); stem(abs(xpad*exp(-1i*(n'*w*k)))); title('10-Point DFT of Input Signal');
  1 Kommentar
Les Beckham
Les Beckham am 20 Nov. 2023
Do you have a question?
Please format your code properly if you expect anyone to be able to read it.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Get Started with Signal Processing Toolbox finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by