Interpolation
- From: "Udayarc Nukalapati" <udayarc@xxxxxxxxx>
- Date: Tue, 8 Jan 2008 21:52:02 +0000 (UTC)
I have a problem when running the following code
fid = fopen('xyz.txt', 'r');
A = fscanf(fid, ['%d' '%d' '%f']);
s = size(A);
q = max(s);
w = 1;
for i = 1:3:q
x(w) = A(i);
w = w +1;
end
w=1;
for i = 2:3:q
y(w) = A(i);
w = w +1;
end
w=1;
for i = 3:3:q
z(w) =40-39 * A(i);
if(z(w)>10)
z(w) = 5.0;
end
w = w +1;
end
xres=30;
yres=37;
xmin = min(x); ymin = min(y);
xmax = max(x); ymax = max(y);
yv = linspace(xmin, xmax, yres);
xv = linspace(ymin, ymax, xres);
%X = [0 0; 0 1e-10; 0 0; 1 1];
%K = convhulln(X,{'Qt','Pp'});
[Xinterp,Yinterp] = meshgrid(yv,xv);
Zinterp = griddata(x,y,z,Xinterp,Yinterp);
figure
mesh(Xinterp,Yinterp,Zinterp)
colormap(cool(8))
xlabel X; ylabel Y; zlabel Z;
%
% for i = 1:1:36
% for j = 1:1:29
% fid1 = fopen('depthpoints.dat','wt');
%
% fprintf(fid,'%d\n',44);
% fprintf(fid,'%d %d %d\n',0,0,0);
% fprintf(fid,'%d\n',1);
%
% eight=0;
% rows=0;
% cols=1;
% p = 1
% true1 = 0;
%
% for i = 1 : 1 : 32
% p = 1;
% for j=1:1:25
%
% true1 = 0;
% if(p <=32)
% p = p+1;
% fprintf(fid,'%f ',Zinterp(i,j));
% eight=eight+1;
% if(eight==8)
% true1 = 1;
% fprintf(fid,'\n');
% eight=0;
% %j = j -1;
% end
% end
% end
%
%
%
% if(true1 == 0)
% fprintf(fid,'\n');
% end
% cols=cols+1;
% % fprintf(fid,'%d\n');
% fprintf(fid,'%d\n',cols);
% end
fid2 = fopen('correcteddepthpoints1.dat','wt');
fprintf(fid2,'%d\n',44);
fprintf(fid2,'%d %d %d\n',0,0,0);
fprintf(fid2,'%d\n',1);
eight=0;
rows=0;
cols=1;
p = 1
true1 = 0;
for j = 37 : -1 : 1
p=1;
for i=1:1:30
true1 = 0;
if(p <=32)
p = p+1;
fprintf(fid2,'%f ',Zinterp(i,j));
eight=eight+1;
if(eight==8)
true1 = 1;
fprintf(fid2,'\n');
eight=0;
%j = j -1;
end
end
end
while(p<=32)
p = p+1;
fprintf(fid2,'%f ',5.0000);
eight=eight+1;
if(eight==8)
true1 = 1;
fprintf(fid2,'\n');
eight=0;
end
end
if(true1 == 0)
fprintf(fid2,'\n');
end
cols=cols+1;
% fprintf(fid,'%d\n');
fprintf(fid2,'%d\n',cols);
end
k = 0;
while(cols<=44)
for i = 1 : 1 : 32
if(k == 8)
fprintf(fid2,'\n');
k = 0;
end
fprintf(fid2,'%f ',5.0000);
k = k + 1;
end
cols = cols + 1;
fprintf(fid2,'\n%d',cols);
end
fclose(fid2);
Error which I got is
??? qhull precision warning:
The initial hull is narrow (cosine of min. angle is
1.0000000000000000).
A coplanar point may lead to a wide facet. Options 'QbB'
(scale to unit box)
or 'Qbb' (scale last coordinate) may remove this warning.
Use 'Pp' to skip
this warning. See 'Limitations' in
http://www.qhull.org/html/qh-impre.htm
qhull precision error: initial simplex is not convex.
Distance=-7.1e-015
While executing: | qhull d Qt Qbb Qc
Options selected for Qhull 2003.1 2003/12/30:
delaunay Qtriangulate Qbbound-last Qcoplanar-keep
_pre-merge
_zero-centrum Pgood Qinterior-keep _max-width 1.4e+002
Error-roundoff 2.9e-013 _one-merge 2e-012 Visible-
distance 5.7e-013
U-coplanar-distance 5.7e-013 Width-outside 1.1e-012
_wide-facet 3.4e-012
_narrow-hull 0
The input to qhull appears to be less than 3 dimensional,
or a
computation has overflowed.
Qhull could not construct a clearly convex simplex from
points:
The center point is coplanar with a facet, or a vertex is
coplanar
with a neighboring facet. The maximum round off error for
computing distances is 2.9e-013. The center point, facets
and distances
to the center point are as follows:
facet
p135
p16592
p0
distance= -7.1e-015
facet
p16727
p16592
p0
distance= -1.4e-014
facet
p16727
p135
p0
distance= -7.1e-015
facet
p16727
p135
p16592
distance= -7.1e-015
These points either have a maximum or minimum x-coordinate,
or
they maximize the determinant for k coordinates. Trial
points
are first selected from points that maximize a coordinate.
The min and max coordinates for each dimension are:
0: 65 187 difference= 122
1: 72 207 difference= 135
2: 0 135 difference= 135
If the input should be full dimensional, you have several
options that
may determine an initial simplex:
- use 'QJ' to joggle the input and make it full
dimensional
- use 'QbB' to scale the points to the unit cube
- use 'QR0' to randomly rotate the input for different
maximum points
- use 'Qs' to search all points for the initial simplex
- use 'En' to specify a maximum roundoff error less than
2.9e-013.
- trace execution with 'T3' to see the determinant for
each point.
If the input is lower dimensional:
- use 'QJ' to joggle the input and make it full
dimensional
- use 'Qbk:0Bk:0' to delete coordinate k from the input.
You should
pick the coordinate with the least range. The hull
will have the
correct topology.
- determine the flat containing the points, rotate the
points
into a coordinate plane, and delete the other
coordinates.
- add one or more points to make the input full
dimensional.
This is a Delaunay triangulation and the input is co-
circular or co-spherical:
- use 'Qz' to add a point "at infinity" (i.e., above the
paraboloid)
- or use 'QJ' to joggle the input and avoid co-circular
data
Error in ==> delaunayn at 81
t = qhullmx(x', 'd ', opt);
Error in ==> griddata>linear at 140
tri = delaunayn([x y]);
Error in ==> griddata at 109
zi = linear(x,y,z,xi,yi,opt);
Error in ==> Interpolation at 70
Zinterp = griddata(x,y,z,Xinterp,Yinterp);
Can Anybody help me out. x,y and z are of size 1 X 16728
.
- Prev by Date: Re: dlmread
- Next by Date: save to a mat structure
- Previous by thread: about histogram function
- Next by thread: save to a mat structure
- Index(es):
Relevant Pages
|