preethi19
Full Member level 5
Hi i am trying to convolve two sine waves of the same freq 5KHz. I am able to multiply both in time domain and when i convert i am able to get the spectrum at 10KHz. But rather i want to try for obtaining two 5KHz spectrum and convolving them and checking the result. I tried conv() function in matlab but the spectrum is wrong. Here is my matlab code. Can someone pls let me know the correction. Thank you!!!!
Later if i do simple multiplication "z=x.*y;"
i am able to multiply the waves and then take fft of it. But when i do "sp=conv(mx,my);"
i am not getting desired output spectrum. Can anyone pls tell how to go about. Thank you!!!
Code:
Fs = 150; % Sampling frequency
t = 0:1/Fs:1; % Time vector of 1 second
f = 5; % Create a sine wave of f Hz.
x = sin(2*pi*t*f);
y = sin(2*pi*t*f);
nfft = 1024; % Length of FFT
X = fft(x,nfft);
Y = fft(y,nfft);
X = X(1:nfft/2);
Y = Y(1:nfft/2);
mx = abs(X);
my = abs(Y);
f = (0:nfft/2-1)*Fs/nfft;
figure(1);
plot(t,x);
figure(2);
plot(t,y);
% plotting both sine waves of 5KHz
figure(3);
plot(f,mx);
figure(4);
plot(f,my);
%plotting their spectrum
Later if i do simple multiplication "z=x.*y;"
i am able to multiply the waves and then take fft of it. But when i do "sp=conv(mx,my);"
i am not getting desired output spectrum. Can anyone pls tell how to go about. Thank you!!!