% Get the script folder scriptFolder = fileparts(mfilename('fullpath')); % Find the HDF5 file in the folder files = dir(fullfile(scriptFolder, '*.h5')); if isempty(files) error('No HDF5 files found in the script folder.'); end % Select the first matching file (modify as needed) filename = files(6).name; % filename = 'Pmod_8p0023dBm_P_PD_6p4776dBm_W03C34-0409E03_64GBd_2PAM__20250218T181323.h5'; % Extract parameters from the filename using an updated regex tokens = regexp(filename, 'Pmod_([-0-9p]+)dBm_P_PD_([-0-9p]+)dBm_.*?_(\d+)GBd_(\d+)PAM__\d+T\d+', 'tokens'); if isempty(tokens) error('Filename format not recognized.'); end tokens = tokens{1}; % Convert values P_laser = str2double(strrep(tokens{1}, 'p', '.')); P_pd = str2double(strrep(tokens{2}, 'p', '.')); fsym = str2double(tokens{3}) * 1e9; % Convert GBd to Hz M = str2double(tokens{4}); % Display results fprintf('Loaded file: %s\n', filename); fprintf('P_laser: %.3f dBm\n', P_laser); fprintf('P_pd: %.3f dBm\n', P_pd); fprintf('fsym: %.3f Hz\n', fsym); fprintf('M: %d\n', M); %%% Load Data folder = "/Users/silasoettinghaus/Documents/MATLAB/imdd_simulation/projects/Messung_Zürich"; filepath = fullfile(folder,filename); ief_ = h5info(filepath); fs_rx = h5readatt(filepath,'/','fs'); %sampling frequency at Rx fs_tx = h5readatt(filepath, '/','fs_Tx'); %sampling frequency at Tx fsym = h5readatt(filepath, '/','R'); %Baudrate M = h5readatt(filepath, '/','M'); % PAM- 'M' ROF = h5readatt(filepath, '/','ROF'); PulseShape =h5readatt(filepath, '/','PulseShape'); yOrg = h5readatt(filepath, ief_.Groups(4).Groups(1).Name, 'YOrg'); yInc = h5readatt(filepath, ief_.Groups(4).Groups(1).Name, 'YInc'); plotDisplayName = sprintf('P_{cw} = %.3f dBm, P_{PD} = %.3f dBm, f_{sym} = %.3f GBd, M = %d', ... P_laser, P_pd, fsym / 1e9, M); dataRx = double(h5read(filepath, '/Waveforms/Channel 2/Channel 2Data')); % rohdaten des CH4 bitsTx = h5read(filepath, '/Settings/dataTx'); %Binär bitsTx = reshape(bitsTx,log2(M),[])'; %%% Build Tx Signal (Bits, Pam Map, Symbols) Tx_bits = Informationsignal(bitsTx); Tx_symbols = PAMmapper(M,0,"eth_style",1).map(Tx_bits); Tx_symbols.fs = fsym; % Tx_symbols.plot("fignum",1,"displayname",'Rx Signal'); % Tx_symbols.move_it_spectrum("fignum",2,"displayname",'tx spectrum'); % Tx_symbols.spectrum("fignum",3,"displayname",'Rx Signal','normalizeTo0dB',0); %%% Build Rx Signal (Rx, normalize,remove mean) dataRx = dataRx*yInc+yOrg; Rx_Sig = Informationsignal(dataRx,"fs",fs_rx); Rx_Sig = Rx_Sig.normalize("mode","rms"); % Rx_Sig.power(); % Rx_Sig.eye(fsym,M,"fignum",4,"displayname",'eye diagram'); % Rx_Sig.plot("fignum",5,"displayname",'Rx Signal'); % Rx_Sig.move_it_spectrum("fignum",6,"displayname",'tx spectrum'); Rx_Sig.spectrum("fignum",3,"displayname",'Rx Signal','normalizeTo0dB',0); %%%%%% Sample to 2x fsym %%%%%% Rx_Sig_resamp = Rx_Sig.resample("fs_out",2*fsym); %%%%%% Sync Rx signal with reference (S is a cell array with all occurences) %%%%%% [Rx_Sig_sync,S,isFlipped] = Rx_Sig_resamp.tsynch("reference",Tx_symbols,"fs_ref",fsym,"debug_plots",0); eq_vnle_dfe = EQ("Ne",[50,7,7],"Nb",[0,0,0],"training_length",4096*2,"training_loops",5,"dd_loops",5,"K",2,"DCmu",0.05,"DDmu",[0.0004 0.0004 0.0004 0.0004 ],"DFEmu",0.005,"FFEmu",0,"plotfinal",1,"ideal_dfe",0); [result] = vnle(eq_vnle_dfe,M,Rx_Sig_sync,Tx_symbols,Tx_bits,"precode_mode",db_mode.no_db,"showAnalysis",1,'eth_style',1);