read and write same file VTU

22 visualizaciones (últimos 30 días)
vaya putra
vaya putra el 2 de Jul. de 2019
hi
i want to read and write VTU file and then visualize using Paraview.
from original VTU file i already done open and visualize it.
but i am trying to write in same script using
fprintf (B,....,... till end of input file)
the point that i have done want to update result from MATLAB (value E and F)
B = fopen('outp.vtu','w');
fprintf(B,'<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt64">');
fprintf(B,'\n <UnstructuredGrid>');
fprintf(B,'\n <Piece NumberOfPoints="72" NumberOfCells="25">');
fprintf(B,'\n </DataArray> \n </PointData> \n <CellData Scalars="pressure">');
fprintf(B,'\n <DataArray type="Float64" Name="pressure" format="ascii" RangeMin="50" RangeMax="80">');
fprintf(B,'\n %2.2f', E'); % update value from Matlab
fprintf(B,'\n </DataArray>');
fprintf(B,'\n <DataArray type="Float64" Name="temperature" format="ascii" RangeMin="200" RangeMax="380">');
fprintf(B,'\n %2.2f', F); % update value from Matlab
fprintf(B,'\n </DataArray> \n </CellData> \n <Points>');
fprintf(B,['\n 0 0 0 1 0 0 \n 2 0 0 3 0 0 \n 4 0 0 5 0 0 \n 5 1 0 4 1 0 \n 3 1 0 2 1 0' ...
'\n 1 1 0 0 1 0 \n 5 2 0 4 2 0 \n 3 2 0 2 2 0\n 1 2 0 0 2 0 \n 5 3 0 4 3 0 \n 3 3 0 2 3 0' ...
'\n 1 3 0 0 3 0 \n 5 4 0 4 4 0 \n 3 4 0 2 4 0 \n 1 4 0 0 4 0 \n 5 5 0 4 5 0' ...
'\n 3 5 0 2 5 0 \n 1 5 0 0 5 0 \n 0 0 1 1 0 1 \n 2 0 1 3 0 1 \n 4 0 1 5 0 1' ...
'\n 5 1 1 4 1 1 \n 3 1 1 2 1 1 \n 1 1 1 0 1 1 \n 5 2 1 4 2 1 \n 3 2 1 2 2 1' ...
'\n 1 2 1 0 2 1 \n 5 3 1 4 3 1 \n 3 3 1 2 3 1 \n 1 3 1 0 3 1 \n 5 4 1 4 4 1' ...
'\n 3 4 1 2 4 1 \n 1 4 1 0 4 1 \n 5 5 1 4 5 1 \n 3 5 1 2 5 1 \n 1 5 1 0 5 1']);
fprintf(B,['\n </DataArray> \n </Points> \n <Cells>'...
'\n <DataArray type="Int64" Name="connectivity" format="ascii" ' ...
'RangeMin="0" RangeMax="71">']);
fprintf(B,['\n0 1 10 11 36 37 \n46 47 1 2 9 10 \n37 38 45 46 2 3 \n8 9 38 39 44 45 \n3 4 7 8 39 40 ' ...
'\n43 44 4 5 6 7 \n40 41 42 43 11 10 \n16 17 47 46 52 53 \n10 9 15 16 46 45 \n51 52 9 8 14 15 ' ...
'\n45 44 50 51 8 7 \n13 14 44 43 49 50 \n7 6 12 13 43 42 \n48 49 17 16 22 23 \n53 52 58 59 16 15 '...
'\n21 22 52 51 57 58 \n15 14 20 21 51 50 \n56 57 14 13 19 20 \n50 49 55 56 13 12 \n18 19 49 48 54 55 ' ...
'\n23 22 28 29 59 58 \n64 65 22 21 27 28 \n58 57 63 64 21 20 \n26 27 57 56 62 63 \n20 19 25 26 56 55 ' ...
'\n61 62 19 18 24 25 \n55 54 60 61 29 28 \n34 35 65 64 70 71 \n28 27 33 34 64 63 \n69 70 27 26 32 33 ' ...
'\n63 62 68 69 26 25 \n31 32 62 61 67 68 \n25 24 30 31 61 60 \n66 67 ']);
fprintf(B,['\n</DataArray> ' ...
'\n <DataArray type="Int64" Name="offsets" format="ascii" RangeMin="8" RangeMax="200">' ...
'\n 8 16 24 32 40 48 ' ...
'\n 56 64 72 80 88 96 ' ...
'\n 104 112 120 128 136 144 ' ...
'\n152 160 168 176 184 192 200 ' ...
'\n </DataArray> ' ...
'\n<DataArray type="UInt8" Name="types" format="ascii" RangeMin="12" RangeMax="12"> ' ...
'\n12 12 12 12 12 12 ' ...
'\n12 12 12 12 12 12 ' ...
'\n12 12 12 12 12 12' ...
'\n12 12 12 12 12 12 12 ' ...
'\n </DataArray>' ...
'\n</Cells>' ...
'\n</Piece>' ...
'\n</UnstructuredGrid>' ...
'\n</VTKFile>']);
i got error from Paraview below :
Error parsing XML in stream at line 113, column 3, byte index 1616: mismatched tag
Error parsing input file. ReadXMLInformation aborting.
this error come from connectivity grid, since i compare with original VTU file.
connectivity data all same?
any comments that what i have done?
thank you for help

Respuestas (0)

Categorías

Más información sobre Stateflow en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by