classdef Photodiode %PGOTODIODE Summary of this class goes here % Detailed explanation goes here properties fsimu responsivity dark_current temperature end methods function obj = Photodiode(options) %PHOTODIODE Construct an instance of this class % Detailed explanation goes here arguments options.fsimu options.responsivity = 1; options.dark_current = 0; options.temperature = 20; end obj.fsimu = options.fsimu; obj.responsivity = options.responsivity; obj.dark_current = options.dark_current; obj.temperature = options.temperature; end function yout = process(obj,xin) %METHOD1 Summary of this method goes here % Detailed explanation goes here k = Constant.Boltzmann; T = obj.temperature + 273.15 ; %celsius + 273 = kelvin R = 50; %resistance of phdiode (50ohm is typical value) % Magnitude squared detection yout = sum( abs(xin) .^2*obj.responsivity,1) ; % Shot Noise shot_noise = sqrt(k * obj.fsimu .* yout) .* randn(1,size(yout,1)); yout = yout + shot_noise; % Thermal Noise therm_current_psd = (2 * k * T / R ) ; %squared Bw = obj.fsimu; %is this correct? shouldnt it be the bandwidth of the actual component? e.g. 70GHz? therm_noise_pow = therm_current_psd * 2 * Bw; %squared therm_noise = sqrt(therm_noise_pow) .* randn(1,size(yout,1)); yout = yout + therm_noise; % Dark Current yout = yout + obj.dark_current ; end end end