From ea71dce1c34c01a198f78ef72019403bcb8efd59 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Fri, 22 Jul 2011 10:02:09 +0200 Subject: [PATCH] matlab: some fixes in field interpolation and vtk dump --- matlab/Dump2VTK.m | 7 ++----- matlab/GetField_Interpolation.m | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/matlab/Dump2VTK.m b/matlab/Dump2VTK.m index 5c01435..fb1c23d 100644 --- a/matlab/Dump2VTK.m +++ b/matlab/Dump2VTK.m @@ -80,7 +80,7 @@ fprintf(fid,'\n\n'); fprintf(fid,'POINT_DATA %d\n',numel(x)*numel(y)*numel(z)); % dump vector field data -if (ndims(fields)==4) +if (size(fields,4)>1) if (nargin>3) fprintf(fid,['VECTORS ' fieldname ' double\n']); else @@ -96,10 +96,7 @@ if (ndims(fields)==4) dumpField(:,3) = field_z(:); save('-ascii','-append',filename,'dumpField') return -end - -% dump scalar field data -if (ndims(fields)==3) +elseif (size(fields,4)==1) % scalar field if (nargin>3) fprintf(fid,['SCALARS ' fieldname ' double 1\nLOOKUP_TABLE default\n']); else diff --git a/matlab/GetField_Interpolation.m b/matlab/GetField_Interpolation.m index 787ef65..f62031f 100644 --- a/matlab/GetField_Interpolation.m +++ b/matlab/GetField_Interpolation.m @@ -70,7 +70,7 @@ if (numel(x)==1) [Y_I Z_I] = ndgrid(y_i,z_i); for n=1:numel(field.values) field_i.values{n}(1,:,:,1) = interpn(Y,Z,squeeze(field.values{n}(1,:,:,1)),Y_I,Z_I); - if (size(field_i.values{n},4)>1) + if (size(field.values{n},4)>1) field_i.values{n}(1,:,:,2) = interpn(Y,Z,squeeze(field.values{n}(1,:,:,2)),Y_I,Z_I); field_i.values{n}(1,:,:,3) = interpn(Y,Z,squeeze(field.values{n}(1,:,:,3)),Y_I,Z_I); end @@ -83,7 +83,7 @@ if (numel(y)==1) [X_I Z_I] = ndgrid(x_i,z_i); for n=1:numel(field.values) field_i.values{n}(:,1,:,1) = interpn(X,Z,squeeze(field.values{n}(:,1,:,1)),X_I,Z_I); - if (size(field_i.values{n},4)>1) + if (size(field.values{n},4)>1) field_i.values{n}(:,1,:,2) = interpn(X,Z,squeeze(field.values{n}(:,1,:,2)),X_I,Z_I); field_i.values{n}(:,1,:,3) = interpn(X,Z,squeeze(field.values{n}(:,1,:,3)),X_I,Z_I); end @@ -96,7 +96,7 @@ if (numel(z)==1) [X_I Y_I] = ndgrid(x_i,y_i); for n=1:numel(field.values) field_i.values{n}(:,:,1,1) = interpn(X,Y,squeeze(field.values{n}(:,:,1,1)),X_I,Y_I); - if (size(field_i.values{n},4)>1) + if (size(field.values{n},4)>1) field_i.values{n}(:,:,1,2) = interpn(X,Y,squeeze(field.values{n}(:,:,1,2)),X_I,Y_I); field_i.values{n}(:,:,1,3) = interpn(X,Y,squeeze(field.values{n}(:,:,1,3)),X_I,Y_I); end @@ -110,7 +110,7 @@ end [X_I Y_I Z_I] = ndgrid(x_i,y_i,z_i); for n=1:numel(field.values) field_i.values{n}(:,:,:,1) = interpn(X,Y,Z,field.values{n}(:,:,:,1),X_I,Y_I,Z_I); - if (size(field_i.values{n},4)>1) + if (size(field.values{n},4)>1) field_i.values{n}(:,:,:,2) = interpn(X,Y,Z,field.values{n}(:,:,:,2),X_I,Y_I,Z_I); field_i.values{n}(:,:,:,3) = interpn(X,Y,Z,field.values{n}(:,:,:,3),X_I,Y_I,Z_I); end