-
Notifications
You must be signed in to change notification settings - Fork 2
/
UDWithScale.m
43 lines (38 loc) · 1.26 KB
/
UDWithScale.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function [X_scaled,Xij]=UDWithScale(n,s,coli,min_ranges_p,max_ranges_p,uns);
Xij=(uns-0.5)/n;
Xij_i=Xij(:,:,coli);
%% scale to any interval
% in_ranges_p: [1xp] or [px1] vector that contains p values that correspond to the minimum value of each variable
% max_ranges_p: [1xp] or [px1] vector that contains p values that correspond to the maximum value of each variable
% coli : column index for uniform variable matrix.
% Xij : X location cal from Uij
% Latin Hypercube
% version 1.0 (2.38 KB) by Nassim Khaled
% lhsdesign_modified generates latin hypercube samples
% http://cn.mathworks.com/matlabcentral/fileexchange/45793-latin-hypercube
%
plen=length(min_ranges_p);
if s~=plen
error(sprintf('minimum value of each variable should be %d',s) )
end
if s~=length(max_ranges_p)
error(sprintf('maximum value of each variable should be %d',s) )
end
[M,N]=size(min_ranges_p);
if M<N
min_ranges_p=min_ranges_p';
end
[M,N]=size(max_ranges_p);
if M<N
max_ranges_p=max_ranges_p';
end
slope=max_ranges_p-min_ranges_p;
offset=min_ranges_p;
SLOPE=ones(n,plen);
OFFSET=ones(n,plen);
for i=1:plen
SLOPE(:,i)=ones(n,1).*slope(i);
OFFSET(:,i)=ones(n,1).*offset(i);
end
% scaled results
X_scaled=SLOPE.*Xij_i+OFFSET