<div class="gmail_quote">Hi,<br><div><br></div><div>I have point cloud data in the form of 3 vectors, x y z which are n-by-1 and contain the 3 coordinates of the points. I am trying to swiftly generate a .vtk file in MATLAB so I can view it in Paraview, but I am having trouble understanding the documentation at <a href="http://www.vtk.org/VTK/img/file-formats.pdf" target="_blank">http://www.vtk.org/VTK/img/file-formats.pdf</a></div>
<div><br></div><div>I have written some code, where I write the points as an unstructred grid, but paraview doesn't show anything when I try to view the file.</div><div><br></div><div>Here's my code:</div><div><br>
</div><div><div>function [] = write_vtk(x,y,z)</div><div><br></div><div> n=size(x);</div><div> delete('data.vtk');</div><div> fid=fopen('data.vtk','w');</div><div> fprintf(fid,'# vtk DataFile Version 2.0\n');</div>
<div> fprintf(fid,'blah\n');</div><div> fprintf(fid,'ASCII\n');</div><div> fprintf(fid,'DATASET UNSTRUCTURED_GRID\n');</div><div> fprintf(fid,'POINTS %d float\n',n);</div><div>
for i=1:n</div>
<div> fprintf(fid,'%f %f %f\n',x(i),y(i),z(i));</div><div> end</div><div> fprintf(fid,'POINT_DATA %d\n',n);</div><div> fclose(fid);</div><div> </div><div><br></div><div>end</div></div>
<div>
<br></div><div>What am I doing wrong?</div><div><br></div><br clear="all">Haluk Noyan Tokgozoglu<div><br></div><div>Johns Hopkins University</div><div>Computer Science PhD Student</div><div>Computational Interaction and Robotics Library</div>
<div>Secretary of the GRO</div><div>Treasurer of UPE</div><br>
</div><br>