% 
% This program simulates an attenuator 
% Input parameter - Attenuation constant [dB] 
% 
 
% Create an output structure similar to the input 
OutputPort1 = InputPort1; 
 
% Attenuation constant 
Attenuation = Parameter0; 
% calculate the optical signal attenuation 
if(InputPort1.TypeSignal == 'Optical') 
 
 % verify how many sampled signals are in the structure 
 [ls, cs] = size(InputPort1.Sampled); 
 
 
 if( ls > 0 ) 
 % caculate the attenuation at each signal 
 for counter1=1:cs 
 OutputPort1.Sampled(1, counter1).Signal = InputPort1.Sampled(1, counter1).Signal * exp(-0.2303 * Attenuation / 2); 
 end 
 end 
 
end