DSB - FC (Conventional AM) using scilab

Aim: Write scilab code to get the DSB-FC Amplitude 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') 
T=input('enter the duration over which the signal is to be plotted') 
fs=input('enter the sampling frequency') 
t=0:T/fs:T-(T/fs); //generation of Modulating and Carrier signals
 m=cos(2*%pi*f1*t)
   n=cos(2*%pi*f2*t)                     //generation of AM signal
 M=(A+m).*n //Rectification during Demodulation
 M(find(M<0))=0 
Y=T*f2 
Z=length(t)/Y
 B=zeros(1,Y) P=B 
 for i=1:Y  
   [d n]=max[M(Z*(i-1)+1:Z*i]      
P(i)=Z*(i-1)+n      
B(i)=(d/n(P(i))-A
 end 
t1=0:T/fs:(length(B)-1)*T/fs 
subplot(2,1,1)
 plot2d1(t1,B) 
xgrid
subplot(2,1,2)
plot2d1(t,M)

 

enter the un-modulated carrier signal peak Amplitude2

enter the baseband signal frequency10

enter the carrier signal frequency100

enter the duration over which the signal is to be plotted0.15

enter the sampling frequency400