
sir = [20:2:36];  %decibel = attenuation of interference path
laser_linewidth = [1e5 1e6 3e6 10e6];
pn_key = [1:10];
vp = [0.25];
vb = [1:0.1:1.8];
rop = -9:3;

sir = [20:2:36];  %decibel = attenuation of interference path
laser_linewidth = [1e5 1e6 10e6];
pn_key = [1:10];
vp = [0.25,0.5,0.75,1];
vb = [1:0.1:1.8];
rop = -5:0;

params = struct;
params.sir = [20:2:36];  %decibel = attenuation of interference path
params.laser_linewidth = [1e5 1e6 10e6];
params.pn_key = [1:10];
params.vp = [0.25,0.5,0.75,1];
params.vb = [1:0.1:1.8];
params.rop = -5:0;
wh = DataStorage(params);
wh.addStorage("ber");
wh.addStorage("level_avg");
wh.addStorage("level_std");
wh.addStorage("rop_save");
wh.addStorage("cspr");
wh.addStorage("mod_out_pow");


cnt = 1;
for s = 1:length(sir)
    for l = 1:length(laser_linewidth)
        for pnk = 1:length(pn_key)
            for n = 1:length(vp)
                for m = 1:length(vb)
                    for i = 1:length(rop)
                        cnt = cnt +1;
                        
                        wh.addValueToStorage(BER(s,l,pnk,n,m,i),'ber',sir(s),laser_linewidth(l),pn_key(pnk),vp(n),vb(m),rop(i));
%                         wh.addValueToStorage(level_avg(s,l,pnk,n,m,i,:),'level_avg',sir(s),laser_linewidth(l),pn_key(pnk),vp(n),vb(m),rop(i));
%                         wh.addValueToStorage(level_std(s,l,pnk,n,m,i,:),'level_std',sir(s),laser_linewidth(l),pn_key(pnk),vp(n),vb(m),rop(i));
                        wh.addValueToStorage(rop_save(s,l,pnk,n,m,i),'rop_save',sir(s),laser_linewidth(l),pn_key(pnk),vp(n),vb(m),rop(i));
                        wh.addValueToStorage(cspr(s,l,pnk,n,m),'cspr',sir(s),laser_linewidth(l),pn_key(pnk),vp(n),vb(m),rop(i));
                        wh.addValueToStorage(mod_out_pow(s,l,pnk,n,m),'mod_out_pow',sir(s),laser_linewidth(l),pn_key(pnk),vp(n),vb(m),rop(i));
                        
                    end
                end
            end
        end
    end
end

% 4) Hey! the warehouse is here and (hopefully) filled with data  :-)

% Create a save dialog
defaultDir = 'C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\MPI_April';
defaultExt = '*.mat';
[filename, pathname] = uiputfile(fullfile(defaultDir, defaultExt),'', 'wh.mat');

% Check if the user pressed Cancel
if isequal(filename, 0) || isequal(pathname, 0)
    disp('Save operation canceled.');
else
    % Save the variable to the selected file
    save(fullfile(pathname, filename), 'wh');
    disp(['Variable "wh" saved to: ', fullfile(pathname, filename)]);
end