Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/examples/Test_Scattered2DDataInterpolator/randomFile.m
3203 views
1
%% matlab function to generate sparse datasets
2
%%% 1 with random point positions
3
%%% 1 along 2 fictive "flight" lines
4
function randomFile
5
6
%%%%% generate a data set with random point positions
7
xx=rand(200,2);
8
9
xyz(:,1)=210e03*xx(:,1)-5e03;
10
xyz(:,2)=60e03*xx(:,2)-5e03;
11
12
for ii=1:size(xx,1)
13
xyz(ii,3)=zs(xyz(ii,1),xyz(ii,2));
14
end
15
16
save('Rand200.txt','xyz','-ASCII');
17
18
%%%%% generate a data set along two "flight" lines at y=15km and y=30km
19
xgrid=-1000:500:201000;
20
n1=size(xgrid,2);
21
22
xyz2(1:n1,1)=xgrid;
23
xyz2(1:n1,2)=15000;
24
25
26
xyz2(n1+1:n1+n1,1)=xgrid;
27
xyz2(n1+1:n1+n1,2)=30000;
28
29
for ii=1:size(xyz2,1)
30
xyz2(ii,3)=zs(xyz2(ii,1),xyz2(ii,2));
31
end
32
33
save('FlightLines.txt','xyz2','-ASCII');
34
35
36
%%%% The "True" variable
37
function zs = zs(x,y)
38
Lx = 200.0e3;
39
Ly = 50.0e03;
40
zs=500.0-1.0e-03*x+20.0*(sin(3.0*pi*x/Lx)*sin(2.0*pi*y/Ly));
41
end
42
43
end
44
45