DSB - FC using diode detector

Aim: Write scilab code to get the DSB-FC Amplitude Modulation using diode detector

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 
RC=1/(2*%pi*f1) 
V=zeros(1,length(M)) 
V(1)=1 
 for i=2:length(M)    
     if  M(i)>V(i-1)          
V(i)=M(i)     
    Else           
V(i)=V(i-1)*exp(-T/(RC*fs))
     end 
end 
plot(t,M,t,V)

 

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