Matlab problem about AM and FM

  • MATLAB
  • Thread starter kidd
  • Start date
  • Tags
    Fm Matlab
In summary, your program simulates an amplitude modulation (AM) waveform in time and frequency domain. The frequency modulation (FM) waveform is also simulated in time and frequency domain. The program is set up to plot the AM waveform and the FM waveform on the same figure. The amplitude of the AM waveform is plotted as a function of time and the amplitude of the FM waveform is plotted as a function of frequency. The program also calculates the modulating signal (Vm) and the carrier signal (Vc) and plots them on the figure.
  • #1
kidd
15
0
The question is like this:
a.The amplitude modulation(AM)waveform in time and frequency domain.
fm=20HZ,fc=500HZ,Vm=1V,Vc=1V,t=0:0.00001:0.09999

a.The frequency modulation(FM)waveform in time and frequency domain.
fm=250HZ,fc=5KHZ,Vm=1V,Vc=1V,m=10,t=0:0.00001:0.09999

Then my program is like this:
% setting
fm=20;
fc=500;
vm=1;
vc=1;
interval=0.001;
% x-axis:Time(second)
t=0:0.00001:0.09999;
f=0:1:9999;

% y-axis:Voltage(volt)
wc=2*pi*fc;
wm=2*pi*fm;
V1=vc+vm*sin(wm*t);
V2=-(vc+vm*sin(wm*t));
Vm=vm*sin(wm*t);
Vc=vc*sin(wc*t);
Vam=(1+sin(wm*t)).*(sin(wc*t));
Vf=abs(fft(Vam,10000))/10000;

% Plot figure in time domain
figure;
plot(t,Vam);
hold on;
plot(t,V1,'r'),plot(t,V2,'r');
title('AM waveform time-domain');
xlabel('time'), ylabel('amplitude');
grid on;

% Plot figure in frequency domain
figure;
plot(f*10,Vf);
axis([(fc-2*fm) (fc+2*fm) 0 0.6]);
title('AM waveform frequency-domain');
xlabel('frequency'), ylabel('amplitude');
grid on;

%Plot modulating signal
figure;
plot(t,Vm);
title('AM modulating signal');
xlabel('time'), ylabel('amplitude');
grid on;

%Plot carrier signal
figure;
plot(t, Vc);
title('AM carrier signal');
xlabel('time'), ylabel('amplitude');
grid on;
clear;

Is it correct?It is AM program.If it is wrong can u help me correct it?

% setting
vc=1;
vm=1;
fm=250;
fc=5000;
m=10;
% x-axis:Time(second)
t=0:0.00001:0.09999;
f=0:10:99990;

% y-axis:Voltage(volt)
wc=2*pi*fc;
wm=2*pi*fm;
sc_t=vc*cos(wc*t);
sm_t=vm*cos(wm*t);
kf=1000;
s_fm=vc*cos((wc*t)+10*sin(wm*t));
vf=abs(fft(s_fm,10^4))/5000;

% Plot figure in time domain
figure;
plot(t,s_fm);
hold on;
plot(t,sm_t,'r');
axis([0 0.01 -1.5 1.5]);
xlabel('time(second)'),ylabel('amplitude');
title('FM time-domain');
grid on;

% Plot figure in frequency domain
figure;
plot(f,vf);
axis([ 0 10^4 0 0.4]);
xlabel('frequency'), ylabel('amplitude');
title('FM frequency-domain');
grid on;

%Plot modulating signal
figure;
plot(t,sm_t);
axis([0 0.1 -1.5 1.5]);
title('FM modulating signal');

This is FM.

And can let me know what can i get discussion and conclution from this two program?I not very sure i understand what is it doing...:cry:
 
Physics news on Phys.org
  • #2
I wrote a similar program when I had communication theory. My recommendation is to write your code in conjuction with your class notes. As you work through each small set of code, make the lines you are still unsure about; output to the screen or to a file (though I am not sure how you wrote program lines before understanding their meaning). Then as you gain confidence with each set of code, string them together to construct the complete simulation.

You discuss what your program does and how it simulates a real world application. You conclude how well does your program do what you set out to accomplish. You want to elaborate on this, so that you cover all the important points.
 
Last edited:
  • #3


The first program is correct for AM, but the second program is not entirely correct for FM. Here are some corrections and explanations for the second program:

1. In the setting section, the values for fm and fc should be switched. fm should be 250 and fc should be 5000, as stated in the question.

2. The variable "m" is not used in the program, so it can be removed.

3. In the x-axis for the time domain plot, the values should be from 0 to 0.01 instead of 0.09999, since the time interval is 0.00001 and there are 1000 points plotted.

4. In the y-axis for the time domain plot, the values should be from -1.5 to 1.5 to show the full range of the waveform.

5. In the x-axis for the frequency domain plot, the values should be from 0 to 10000 instead of 10^4, since the number of points in the FFT is 10000.

6. In the y-axis for the frequency domain plot, the values should be from 0 to 0.4 to show the full range of the spectrum.

7. The variable "kf" is not used in the program, so it can be removed.

8. The variable "s_fm" should be calculated using the formula for frequency modulation, which is s_fm = vc*cos(wc*t + kf*vm*cos(wm*t)). In the program, the value of kf is set to 1000, which is the deviation constant for a 1kHz signal. If the question did not specify a value for kf, it is usually assumed to be 1.

9. The FFT should be calculated using 10000 points, not 5000, since the sampling frequency is 10000 Hz.

10. The title for the time domain plot should be "FM waveform time-domain" instead of "AM waveform time-domain".

11. The title for the frequency domain plot should be "FM waveform frequency-domain" instead of "AM waveform frequency-domain".

12. The title for the modulating signal plot should be "FM modulating signal" instead of "AM modulating signal".

13. The amplitude of the modulating signal should be multiplied by 10 to match the m value in the question.

14. The carrier signal plot is not necessary for FM, so it can be removed.

As
 

1. What is the difference between AM and FM in Matlab?

AM and FM are two different methods of encoding information onto a carrier signal in Matlab. AM, or amplitude modulation, varies the amplitude of the carrier signal to represent the information, while FM, or frequency modulation, varies the frequency of the carrier signal. In other words, AM changes the height of the signal, while FM changes the spacing between the peaks of the signal.

2. How do I generate an AM signal in Matlab?

To generate an AM signal in Matlab, you can use the "ammod" function. This function takes in the carrier signal, message signal, and modulation index as inputs and outputs the AM signal. The modulation index determines the amplitude of the carrier signal, and the message signal is the information you want to encode onto the carrier signal.

3. Can I plot an AM signal in Matlab?

Yes, you can plot an AM signal in Matlab using the "plot" function. First, you need to generate the AM signal using the "ammod" function and store it in a variable. Then, you can use the "plot" function to plot the signal against time. This will give you a visual representation of the AM signal.

4. How do I demodulate an FM signal in Matlab?

To demodulate an FM signal in Matlab, you can use the "demod" function. This function takes in the FM signal, carrier frequency, and modulation index as inputs and outputs the demodulated signal. The carrier frequency and modulation index must be the same values used to generate the FM signal.

5. Can I apply noise to an AM or FM signal in Matlab?

Yes, you can apply noise to an AM or FM signal in Matlab using the "awgn" function. This function adds white Gaussian noise to the signal, which can simulate real-world interference. The amount of noise can be controlled by adjusting the signal-to-noise ratio (SNR) parameter in the function.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
29
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
Back
Top