Frequency modulation programs (FM program)

Aim: Write scilab code to get the Frequency modulation 

Requirements: PC with Scilab software

Program:

A=input('enter the un-modulated carrier signal peak Amplitude') 
f1=input('enter the baseband signal frequency')
f2=input('enter the carrier signal frequency') 
k= input('enter the frequency Sensitivity') 
T=input('enter the duration over which the signal is to be plotted') 
fs=input('enter the sampling frequency')
 t=0:T/fs:T; //generation of Modulating  signal 
m=cos(2*%pi*f1*t);                        //generation of FM signal 
M1=A*cos(2*%pi*f2*t+(k*2*%pi*cumsum(m)/fs)) 
M=diff(M1) 
M(find(M<0))=0; 
y=T*f2; 
z=(length(t)-1)/y;
 x=zeros(1,y); 
p=x; 
     for i=1:y &nbsp;&nbsp;&nbsp;
 [d n1]=max(M((z*(i-1))+1:i*z)) &nbsp;&nbsp;&nbsp; 
x(i)=z*(i-1)+n1 &nbsp;&nbsp;&nbsp; 
p(i)=d 
     end

 

enter the un-modulated carrier signal peak Amplitude  1

enter the baseband signal frequency  5

enter the carrier signal frequency   20

enter the frequency Sensitivity   4

enter the duration over which the signal is to be plotted   0.4

enter the sampling frequency  200