0
$\begingroup$

AM-demodulation task and I was asked to demodulate the signal in MATLAB and the result should contain three pictures.

plotting the $fft$ the (frequency spectrum)of the signal i was able to determine that the pictures are located at 0.1 , 0.25 and 0.5 frequencies.

The problem is that my code below only plot one picture which is located at 0 and I don't know how plot the shifted pictures that are located at 0.25 and 0.5 frequencies.

I tried to multiply it by complex exponential and still not able to plot the pictures

The main problem is that i need to shift those pictures that are located at 0.25 and 0.5 frequency to the center and apply my low pass filter, however i tried as the following code but failed. please help me.

The is the $fft$ of the signal.

enter image description here

I get a mysterious signal modulated with the message as a signal vector z[n], by running the MATLAB function mkhwdata. The parameters of this function are your social security number in one column vector, e.g. z = mkhwdata ([xxxxxx]); The response from the function will be that a vector z containing the signal z[n], where the vectors first element corresponds to the time index n = 0.

• To convert a vector, e.g. vector s describing the signal s[n], to an image use the provided function present_image. Try for example to watch the signal z[n] directly: present_image (z)

clc
close all;
clear

fc = 0.2;
fs = 0.5;
[z]= mkhwdata([xxxxxxxxx]);

[Z,nu] = tdftfast(z);
%N = length(z);
 n = [-0.5:1/0.5:0.5];
%n = N*(0:N-1);
 mult  = 0.5.*exp(1i*2*0.25*pi.*n)  + 0.5.*exp(-1i*2*0.25*pi.*n);
 mult2 = 0.5.*exp(1i*2*pi*0.5.*n)   + 0.5.*exp(-1i*2*pi*0.5.*n);
 [z1] = ifft(Z.*mult);

 [z2] = ifft(Z.*mult2);

 %Lowpass filter
 [num,den] = butter(9,0.2);

 y  = filter(num,den,z);
 y1 = filter(num,den,z1);
 y2 = filter(num,den,z2);
 figure(4)
 ylabel('Amplitude');
 xlabel('Frequency (hz)');
 subplot(221)
 present_image(z);
 subplot(222)
 present_image(y);
 subplot(223)
 present_image(y1);
 subplot(224)
 present_image(y2);
$\endgroup$
0
+100
$\begingroup$

I think there are some problems with your analysis structure.

First of all, for being able to see from -0.5 to 0.5, without aliasing, you have to sample at 1.

Secondly, if you want to down convert a signal, bring it to DC you need to multiply it with the corresponding cosine in time, or discrete time, or apply the convolution to its spectrum with the corresponding Fourier transformed cosine (a cosine in spectrum is a delta Dirac function on the frequency of the same cosine).

By the way, I do not know what the mkhwdata function does. The solution should look something like this:

clc
close all;
clear

fc = 0.2;
fs = 1; %%%%%%%%%%%%%%%%%%

[z]= mkhwdata([xxxxxxxxx]);

[Z,nu] = tdftfast(z);
%N = length(z);
n = [0:(length(z) - 1)];
%n = N*(0:N-1);
mult  = exp(1i*2*0.25*pi.*n);
mult2 = exp(1i*2*pi*0.5.*n);

% We bring the image to DC
[z1] = (z.*transpose(mult)); 
[z2] = (Z.*transpose(mult2));

%Lowpass filter
[num,den] = butter(9,0.2);

y  = filter(num,den,z);
y1 = filter(num,den,z1);
y2 = filter(num,den,z2);

figure(4)
ylabel('Amplitude');
xlabel('Frequency (hz)');
subplot(221)
present_image(z);
subplot(222)
present_image(y);
subplot(223)
present_image(y1);
subplot(224)
present_image(y2);
$\endgroup$
  • $\begingroup$ Hi I tried with bandpass filter for some reason i was unable to recover the pictures. The mkhwdata function is a vector of images, $\endgroup$ – Adam Jun 15 at 13:28
  • $\begingroup$ Can you plot the spectrum after the filter? It should appear only the frequencies you are searching for. So, z is a vector, a matrix, or what? $\endgroup$ – DaDSPGuy Jun 15 at 13:31
  • $\begingroup$ I will try it now , the z is a vector of images, the plot above is the spectrum of z and from that i read the frequency of images. The first image is located at the center around zero and the second at 0.25 and the third at 0.5 $\endgroup$ – Adam Jun 15 at 13:40
  • $\begingroup$ What do you mean by a vector of images? Images of the original frequency or actual images? $\endgroup$ – DaDSPGuy Jun 15 at 13:43
  • $\begingroup$ let me add the code of those functions $\endgroup$ – Adam Jun 15 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.