Paraview是一个开源的可视化软件。
用到matlab子程序从这里下载
或者到博客末尾复制粘贴
子程序名为 vtkwrite
示例1:
1 load mri 2 D = squeeze(D); 3 vtkwrite('mri.vtk', 'structured_points', 'mri', D)
示例2:云图
1 load wind 2 [cu,cv,cw] = curl(x, y, z, u, v, w); 3 div = divergence(x, y, z, u, v, w); 4 vtkwrite('wind.vtk', 'structured_grid', x, y, z, ... 5 'vectors', 'vector_field', u, v, w, 'vectors', 'vorticity', cu, cv, cw, 'scalars', 'divergence', div);
示例3:二维曲线
1 x = 1:100; 2 y = sin(x); 3 z = sqrt(x); 4 vtkwrite('execute','polydata','lines',x,y,z);
示例4:三角形
1 [x,y,z] = peaks(100); 2 z = .4*z; 3 tri = delaunay(x,y); 4 vtkwrite('peaks.vtk','polydata','triangle',x,y,z,tri);
示例5:四面体
1 d = [-1 1]; 2 [x, y, z] = meshgrid(d, d, d); 3 DT = delaunayTriangulation(x(:), y(:), z(:)); 4 vtkwrite('execute', 'polydata','tetrahedron', x, y, z, DT.ConnectivityList);
vtkwrite
1 function vtkwrite( filename,dataType,varargin ) 2 % VTKWRITE Writes 3D Matlab array into VTK file format. 3 % vtkwrite(filename,'structured_grid',x,y,z,'vectors',title,u,v,w) writes 4 % a structured 3D vector data into VTK file, with name specified by the string 5 % filename. (u,v,w) are the vector components at the points (x,y,z). x,y,z 6 % should be 3-D matrices like those generated by meshgrid, where 7 % point(ijk) is specified by x(i,j,k), y(i,j,k) and z(i,j,k). 8 % The matrices x,y,z,u,v,w must all be the same size and contain 9 % corrresponding position and vector component. The string title specifies 10 % the name of the vector field to be saved. 11 % 12 % vtkwrite(filename,'structured_grid',x,y,z,'scalars',title,r) writes a 3D 13 % scalar data into VTK file whose name is specified by the string 14 % filename. r is the scalar value at the points (x,y,z). The matrices 15 % x,y,z,r must all be the same size and contain the corresponding position 16 % and scalar values. 17 % 18 % vtkwrite(filename,'structured_grid',x,y,z,'vectors',title,u,v,w,'scalars', 19 % title2,r) writes a 3D structured grid that contains both vector and scalar values. 20 % x,y,z,u,v,w,r must all be the same size and contain the corresponding 21 % positon, vector and scalar values. 22 % 23 % vtkwrite(filename, 'structured_points', title, m) saves matrix m (could 24 % be 1D, 2D or 3D array) into vtk as structured points. 25 % 26 % vtkwrite(filename, 'structured_points', title, m, 'spacing', sx, sy, sz) 27 % allows user to specify spacing. (default: 1, 1, 1). This is the aspect 28 % ratio of a single voxel. 29 % 30 % vtkwrite(filename, 'structured_points', title, m, 'origin', ox, oy, oz) 31 % allows user to speicify origin of dataset. (default: 0, 0, 0). 32 % 33 % vtkwrite(filename,'unstructured_grid',x,y,z,'vectors',title,u,v,w,'scalars',