Hi Rounak,
As per my understanding you want to change the precisions of variables created using the lhsdesign().
Currently, when displaying these variables, MATLAB defaults to a precision of 4 digits after the decimal point. However, in your specific case, you need 5 significant digits after the decimal point for the 4th variable.
To address this, you can utilize the ‘format long’ command in MATLAB. This command adjusts the display format to show variables with a higher precision, allowing for the display of more digits after the decimal point.
Additionally, you can adjust the precision after the decimal point using the “round” function.
You can refer the below code for better understanding:
% Set the display format to show the full precision
format long
% Define the number of samples and variables
numSamples = 100;
numVariables = 5;
% Generate Latin hypercube samples
samples = lhsdesign(numSamples, numVariables);
% Define the desired precision for each variable
precision = [3, 3, 3, 5, 3]; % 3 significant digits for variables 1, 2, 3, and 5, 5 significant digits for variable 4
% Adjust the precision of each variable
for i = 1:numVariables
% Convert each sample to the desired precision
samples(:, i) = round(samples(:, i), precision(i));
end
% Display the generated samples
disp('Generated Samples:');
disp(samples);
Please refer the below attached MathWorks Documentation link on ‘round’: