Monday, April 4

MATLAB code for Frequency Modulation [juSt wanNa shaRe]

.FM cOde.


1.Kf=100Hz/V

% setting

vc=50; vm=10;

fm=100; fc=5000;

m=10; kf=100;

% x-axis:Time(s)

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);

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.015 -100 100]); %range

xlabel('Time(s)'),ylabel('Amplitude(V)');

title('FM time domain');

grid on;

% Plot figure in frequency domain

figure;

plot(f,vf);

axis([ 0 10^4 0 20]); %range

xlabel('Frequency(Hz)'), ylabel('Amplitude(V)');

title('FM frequency domain');

grid on;

%Plot modulating signal

figure;

plot(t,sm_t);

axis([0 0.1 -70 70]); %range

xlabel('Time(s)'),ylabel('Amplitude(V)');

title('FM modulating signal');





2. Kf=20Hz/V

% setting

vc=50; vm=10;

fm=100; fc=5000;

m=2; kf=20;

% x-axis:Time(s)

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);

s_fm=vc*cos((wc*t)+2*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.015 -100 100]); %range

xlabel('Time(s)'),ylabel('Amplitude(V)');

title('FM time domain');

grid on;

% Plot figure in frequency domain

figure;

plot(f,vf);

axis([ 0 10^4 0 20]); %range

xlabel('Frequency(Hz)'), ylabel('Amplitude(V)');

title('FM frequency domain');

grid on;

%Plot modulating signal

figure;

plot(t,sm_t);

axis([0 0.1 -70 70]); %range

xlabel('Time(s)'),ylabel('Amplitude(V)');

title('FM modulating signal');





3. Kf=1Hz/V

% setting

vc=50; vm=10;

fm=100; fc=5000;

m=0.1; kf=1;

% x-axis:Time(s)

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);

s_fm=vc*cos((wc*t)+0.1*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.015 -100 100]); %range

xlabel('Time(s)'),ylabel('Amplitude(V)');

title('FM time domain');

grid on;

% Plot figure in frequency domain

figure;

plot(f,vf);

axis([ 0 10^4 0 20]); %range

xlabel('Frequency(Hz)'), ylabel('Amplitude(V)');

title('FM frequency domain');

grid on;

%Plot modulating signal

figure;

plot(t,sm_t);

axis([0 0.1 -70 70]); %range

xlabel('Time(s)'),ylabel('Amplitude(V)');

title('FM modulating signal');






This one aku yg buat...tak sure valid and sesuai ke tak...cOde asal ni aku dapat somewhere dari gOogle jugak just aku tukar mane2 yg sesuai ikot projek aku....ini adelah salah satu assigment picOmm aku sem nie..so sape2 yg ade project yg equal, boleh lah jadikan rujukan...

if ade salah kat mane2 just bgtau okeyh... =)

~thankz~

[UTM Student]

5 comments:

  1. ko reti ea gune coding???aku simulink pandai la... ajr aku wei...

    ReplyDelete
  2. hahaha....xde r reti pown....mcm tu je la yg aku paham....terpakse...simulink aku penah blaja gak dlu tp x hingat langsung da...

    haah..mmg pening...kusut pale pk mnde ni...

    ReplyDelete
  3. you're good, thanks for this :)

    ReplyDelete

kalau korang baik, jangan kutuk aku ::

Follow Me @farahinesa