% eda05_09
% make simulated pressure data

% rows of grid are x
I = 41;
Dx = 1;
xmin = 0;
xmax = 40;
x = xmin + (xmax-xmin)*[0:I-1]'/(I-1);

% columns of grid are y
J = 41;
Dy = 1;
ymin = 0;
ymax = 40;
y = ymin + (ymax-ymin)*[0:J-1]'/(J-1);

% grid 10% populated with data
N = floor(I*J/10);
rowindex=unidrnd(I,N,1);
xobs = x(rowindex);
colindex=unidrnd(J,N,1);
yobs = y(colindex);

kappa = 0.1;
dtrue = 10*sin(kappa*xobs).*exp(-kappa*yobs);
sigmad = 0.1;
dobs = dtrue + random('normal',0.0,sigmad,N,1);

A = zeros(I,J);
for i = [1:N]
    A(rowindex(i),colindex(i)) = dobs(i);
end

eda_draw(' ',A,'caption A');

D=zeros(N,3);
D(:,1)=xobs;
D(:,2)=yobs;
D(:,3)=dobs;

dlmwrite('pressure.txt',D,'\t');

