/usr/share/octave/site/m/octave-epstk/efillmat.m is in octave-epstk 2.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 53 54 55 56 57 58 59 60 61 62 | %%NAME
%% efillmat - fill matrix with interpolated values by given xyz-samples
%%
%%SYNOPSIS
%% matrix=efillmat(xData,yData,zData,dx,dx)
%%
%%PARAMETER(S)
%% xData vector of x-coordinates
%% yData vector of y-coordinates
%% zData vector of z-values
%% dx pixel distance of x-direction
%% dy pixel distance of y-direction
%% matrix interpolated matrix
%%
% written by stefan.mueller@fhr.fraunhofer.de (C) 2010
function matrix= efillmat (xData,yData,zData,dx,dy)
if (nargin ~= 5)
eusage('matrix = efillmat(xData,yData,zData,dx,dy)');
end
minX=min(xData);
maxX=max(xData);
minY=min(yData);
maxY=max(yData);
cols=round((maxX-minX)/dx);
rows=round((maxY-minY)/dy);
dx=(maxX-minX)/cols;
dy=(maxY-minY)/rows;
cols=cols+1;
rows=rows+1;
matrix=ones(rows*cols,1)*NaN;
x=round((xData-minX)/dx);
y=round((maxY-yData)/dy);
matrix(x*rows+y+1)=zData;
matrix=reshape(matrix,rows,cols);
smat=~isnan(matrix);
xr=sum(smat)/cols;
yr=sum(smat')/rows;
[sv sp]=sort([xr yr]);
for i=fliplr(sp)
if i>cols
j=i-cols;
svec=~isnan(matrix(j,:));
x=find(svec);
n=length(x);
if n<cols
xi=find(~svec);
x0=1;z0=matrix(j,x(1));
xn=cols;zn=matrix(j,x(n));
matrix(j,xi)=elineip([x0 x xn],[z0 matrix(j,x) zn],xi);
end
else
svec=~isnan(matrix(:,i));
x=find(svec);
n=length(x);
if n<rows
xi=find(~svec);
x0=0;z0=matrix(x(1),i);
xn=rows+1;zn=matrix(x(n),i);
matrix(xi,i)=elineip([x0 x' xn],[z0 matrix(x,i)' zn],xi')';
end
end
end
|