I want to use UQLab to perform sensitivity analysis on a model, whose input parameters are defined in a .txt file. For e.g.:
E_significant_Wave_Ht: 8.7
E_airdensity: 1.22 kg/m3
E_dirs_bins: 72
E_shear_exponent: 0.085
E_ref_ht_weather_timeseries: 10 m
E_turb_intensity: 0.08
E_ref_ht_weibull: 100 m
E_Wa: 10.46
E_Wk: 2.09
I would like to define InputOpts.Marginals for these 9 model parameters, more specifically assign a distribution to the numeric values here. Based on the assigned distribution, the .txt file will be modified (overwritten) iteratively based on the number of samples defined and then perform sensitivity analysis on the model output.
I am not able to assign marginals (InputOpts.Marginals) to the numeric values in my .txt file. Your help and suggestions will be highly appreciated.
Dear @vinit06
Do I understand correctly that you just want to iteratively overwrite these values in the .txt file with values generated by UQLab?
If so, where exactly are you getting stuck? Are you struggling with UQLab or with Matlab?
Best regards
Styfen
Dear @styfen.schaer
Thank you for reverting.
I am basically stuck in the step where I can replace the numeric values of the parameters into random inputs based on the marginals defined. I simply begin with reading the .txt file and replacing the parameter value:
% Read txt into cell A
fid = fopen(strcat(inputDir, '\Input file original.txt'), 'r');
i = 1;
tline = fgetl(fid);
A{i} = tline
while ischar(tline)
i = i+1;
tline = fgetl(fid);
A{i} = tline;
end
fclose(fid);
% Change cell A
A{1} = char(strcat({'E_significant_Wave_Ht: '}, **??**;
% Write cell A into txt
fid = fopen(strcat(inputDir, '\Input file.txt'), 'w');
for i = 1:numel(A)
if A{i+1} == -1
fprintf(fid,'%s', A{i});
break
else
fprintf(fid,'%s\n', A{i});
end
end
How to assign the marginals (??) in place of the defined parameter value such that the output of the model is deduced based on the random input value in an iterative manner:
Dear @vinit06
I do not understand what you mean by “assign the marginals” in this context. Can you share your full code and explain where it breaks?
Best regards
Styfen
Dear @styfen.schaer
I finally managed to get the code working. The way I was defining the value of the model parameter based on the distribution (my interpretation of marginals) was incorrect. So in the above code, the following changes were made:
A{1} = char(strcat({'E_significant_Wave_Ht: '}, num2str(X(1))));
where the value of X(1) is deduced from the distribution defined:
InputOpts.Marginals(1).Name = 'E_significant_Wave_Ht';
InputOpts.Marginals(1).Type = 'Gaussian';
InputOpts.Marginals(1).Parameters = [8.7 0.1];
Thank you.