Matlab results not matching theory
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clear all;
clc;
Fs = 1000;
Ts = 1/Fs;
t=-1:Ts:1;
%u(t-0.5)
step = zeros(size(t));
step(t>=0.5) = -1;
figure
grid
plot(t,step)
%u(t+0.5)
step2 = zeros(size(t));
step2(t>=-0.5)= 1;
figure
grid
plot(t,step2)
xt=step2+step;
figure
plot(t,xt)
y = conv(xt,xt);
t3 = -2 :Ts:2;
figure
plot(t3,y)
z = conv (y,xt );
t4= -3:Ts:3;
figure
plot(t4,z)
q = conv(z,xt)
t5 = -4:Ts:4
figure
plot(t5,q)
nfft=length(y)*32;
Y = fft(y,nfft);
Y = fftshift(Y);
F=-Fs/2:Fs/nfft:Fs/2-Fs/nfft;
figure
plot(F,abs(Y))
nfft=length(z)*32;
Z=fft(z,nfft);
Z=fftshift(Z);
F=-Fs/2:Fs/nfft:Fs/2-Fs/nfft;
figure
plot(F,abs(Z))
nfft=length(q)*32;
Q=fft(q,nfft);
Q=fftshift(Q);
F=-Fs/2:Fs/nfft:Fs/2-Fs/nfft;
figure
plot(F,abs(Q))
So I have this code, but for the 2nd convolution and 3rd one ( z and q ) the theory shows different results . Is there something wrong in my code or should I recheck the theory and redo it ?
4 commentaires
Image Analyst
le 5 Jan 2018
Modifié(e) : Image Analyst
le 5 Jan 2018
What do you expect the base signal to look like? A square pulse? A negative pulse on the left and positive pulse on the right? I still don't know why you're tacking numbers onto the ends!
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!