Repository navigation
Expand file tree
/
Copy pathExample.m
More file actions
52 lines (48 loc) · 1.3 KB
/
Copy pathExample.m
File metadata and controls
52 lines (48 loc) · 1.3 KB
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
44
45
46
47
48
49
50
51
52
clear;
close all;
clc;
%% 2D
L = [0.5, 0.2]; % Correlation lengths
mu = 10; % Mean value
s2 = 4; % Variance (std dev = 2)
Nmc = 1; % Number of realizations
x = 0:0.05:5; % X
y = 0:0.05:5; % Y
field2D = randomField('weibull', 'gauss', L, mu, s2, Nmc, x, y);
figure('Name', '2D Gaussian Field', 'Color', 'w');
imagesc(x, y, squeeze(field2D)');
axis xy equal;
colorbar;
title(['Gaussian Field (L_x=',num2str(L(1)),', L_y=',num2str(L(2)),')']);
xlabel('X [m]'); ylabel('Y [m]');
colormap(jet);
[R(1,:),xo(1,:),Lc(1)] = corrFromField(field2D, x, 1);
[R(2,:),xo(2,:),Lc(2)] = corrFromField(field2D, y, 2);
figure
hold on
for i=1:2
plot(xo(i,:),R(i,:))
end
%% 3D
x3 = 0:0.1:2;
y3 = 0:0.1:2;
z3 = 0:0.1:2;
L3 = [0.4 0.2 1];
field3D = randomField('weibull', 'gauss', L3, mu, s2, Nmc, x3, y3, z3);
figure('Name', '3D Lognormal Field', 'Color', 'w');
data3D = squeeze(field3D);
slice(x3, y3, z3, data3D, [0.5 1.5], 1, 0.5);
shading interp;
colormap(jet)
colorbar;
title('3D Lognormal Field Slices');
xlabel('X'); ylabel('Y'); zlabel('Z');
view(3);
[R3(1,:),xo3(1,:),Lc3(1)] = corrFromField(field3D, x3, 1);
[R3(2,:),xo3(2,:),Lc3(2)] = corrFromField(field3D, y3, 2);
[R3(3,:),xo3(3,:),Lc3(3)] = corrFromField(field3D, z3, 3);
figure
hold on
for i=1:2
plot(xo3(i,:),R3(i,:))
end