[Paraview] Import structured grid from Matlab

antoine vial kibroutski at gmail.com
Tue Apr 3 11:18:30 EDT 2012


Hello,

I have a set of data that I would like visualize with paraview. I convert
my data in binary vtk via a matlab script but when I try to open it then I
get a lot of errors.

Here is the script I'm using:

 %Output file name
filename=('Test1111.vtk');

tic

nr_of_elements=numel(x);
fid = fopen(filename, 'w');

%ASCII file header
fprintf(fid, '# vtk DataFile Version 3.0\n');
fprintf(fid, 'VTK from Matlab\n');
fprintf(fid, 'BINARY\n\n');
fprintf(fid, 'DATASET STRUCTURED_GRID\n');
fprintf(fid, ['DIMENSIONS ' num2str(numel(x)) ' ' num2str(numel(y)) ' '
num2str(numel(z)) '\n']);
fprintf(fid, ['POINTS ' num2str(nr_of_elements) ' float\n']);
fclose(fid);

%append binary x,y,z data

fid = fopen(filename, 'a');
fwrite(fid, [reshape(x,nr_of_elements,1),  reshape(y,nr_of_elements,1),
reshape(z,nr_of_elements,1)],'float','b');
fprintf(fid, '\nSCALARS intensity float\n'); %ASCII header

%append scalar field
fprintf(fid, 'LOOKUP_TABLE default\n'); %ASCII header
fwrite (fid, reshape(Data,nr_of_elements,1),'float','b'); %binary data

fclose(fid);
toc




I'm using Paraview 3.14.0 on windows 7 64b

Sorry if it's a silly question but I am novice in .vtk

Thx for reading

Kib
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20120403/6d08983b/attachment.htm>


More information about the ParaView mailing list