Is My MATLAB Program for AM and FM Correct?

  • Context: MATLAB 
  • Thread starter Thread starter kidd
  • Start date Start date
  • Tags Tags
    Fm Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 28K views
kidd
Messages
14
Reaction score
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
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: