plotpdf_param.m 1.76 KB
%Function that plots and saves the figures of the conditional pdfs of parameters that are
%used for computing MIRI. It takes in input the struct of the model, the
%folder where the results are saved, the output node of interest and the
%number of independent realizations


function plotpdf_param(folder,variable_name,model,Nr)

nominal_parameters=model.nominal_parameters;
nominal_parameters_name=model.nominal_parameters_name;

derived_parameters=model.derived_parameters;
derived_parameters_name=model.derived_parameters_name;

    try
        load(fullfile(folder,variable_name,'pdf_param.mat'));
        for i=1:length(nominal_parameters)
            figure
            for k=1:Nr
                plot(xbin_param{1,k}(i,:),ks_param{1,k}(i,:),'b',xbin_param{2,k}(i,:),ks_param{2,k}(i,:),'r');
                hold on
            end
            nominal_parameters_name{1,i}
            xlabel(nominal_parameters_name{1,i},'Interpreter','none');
            ylabel('pdf');
            legend('Conditional upper density','Conditional lower density');
            savefig(fullfile(folder,variable_name,nominal_parameters_name{1,i}));
        end
            
         load(fullfile(folder,variable_name,'pdf_param_derived.mat'));
         for i=1:length(derived_parameters)
            figure
            for k=1:Nr
                plot(xbin_param_d{1,k}(i,:),ks_param_d{1,k}(i,:),'b',xbin_param_d{2,k}(i,:),ks_param_d{2,k}(i,:),'r');
                hold on
            end
            xlabel(derived_parameters_name{1,i},'Interpreter','none');
            ylabel('pdf');
            legend('Conditional upper density','Conditional lower density');
            savefig(fullfile(folder,variable_name,derived_parameters_name{1,i}));
        
        end
    catch ME
        errordlg(ME.message)
    end
end