From 326e0aaa31aced883efa1b8cea713a0352e083cb Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Tue, 16 Aug 2011 11:23:44 +0200 Subject: [PATCH] Dump2VTK: replace NaN and Inf with 0 --- matlab/Dump2VTK.m | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/matlab/Dump2VTK.m b/matlab/Dump2VTK.m index fb1c23d..8602321 100644 --- a/matlab/Dump2VTK.m +++ b/matlab/Dump2VTK.m @@ -17,7 +17,21 @@ y = mesh.lines{2}; z = mesh.lines{3}; fid = fopen(filename,'w+'); - + +% set nan values to zero +ind = find(isnan(fields)); +if (~isempty(ind)) + warning('openEMS:Dump2VTK','field contains nan, setting to zero'); + fields(ind)=0; +end + +% set inf values to zero +ind = find(isinf(fields)); +if (~isempty(ind)) + warning('openEMS:Dump2VTK','field contains inf, setting to zero'); + fields(ind)=0; +end + if (mesh.type==0) %write cartesian mesh to vtk fprintf(fid,'# vtk DataFile Version 2.0\n'); fprintf(fid,'Rectilinear Grid by matlab-interface of openEMS\n');