View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Write Cell Array of Structs into a VTK Structured Grid

4.0 | 1 rating Rate this file 6 Downloads (last 30 days) File Size: 3.35 KB File ID: #34738 Version: 1.2
image thumbnail

Write Cell Array of Structs into a VTK Structured Grid



23 Jan 2012 (Updated )

Takes a 3D cell array with (nested) structs and exports it as a VTK structured grid.

| Watch this File

File Information

Each cell of the input cell array must be a struct, possibly nested, and for each point of the input, three properties (or alternatively the cell array indices) are used as VTK coordinates. An arbitrary number of properties are used as values of these points.

The resulting VTK file (which is in ascii encoding) can then be opened and viewed with VTK compatible applications, e.g. ParaView.

The "help" text:
% Writes the content of a cell array into an ascii vtk-file 'FILENAME'
% as a structured grid.
% For details about this kind of data see
% and
% This function takes a 3D cell array of structs. For each struct, it then
% uses either given fields of the struct or its indices as VTK coordinates,
% and other fields as the values of the grid.
% Input:
% filename destination (string)
% cell N1xN2xN3 cell array of structs
% coordinates Cell with three cells of strings. These define what to use
% for the points' coordinates. (Details below)
% values Cell with cells of strings. These define the scalar values
% at each point. (details below)
% Optional input parameters of the form ..., 'name', value, ...:
% header Name of the dataset, will be saved into the file.
% valuenames Names of the values. The defaults are their field names.
% spacing 3x1 matrix of inter-point spacings if indices are used as
% coordinates.
% offset 3x1 matrix of offsets for this case.
% Example usage:
% This example assumes that 'results' is a cell array of structs, where
% each struct has (at least) the following valid fields:
% 'vw', '' and 'effects.charge'
% WriteCellToVTKStructured('test.vtk', results, ...
% {{}, {}, {'effects', 'energy'}}, ...
% {{'vw'}, {'effects' 'charge'}}, ...
% 'offset', [1 0.4 0.1], ...
% 'spacing', [1 0.05 0.1])
% Then use e.g. ParaView to view the resultin file 'test.vtk'.


Write To Vtk and Write Vtk inspired this file.

Required Products MATLAB
MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
13 Aug 2015 cheng joylin

25 Feb 2014 Ahmad Rafsanjani

Hi Daniel, Could you please upload an example of input file?

Comment only
29 May 2013 Daniel Hornung

Hello Romain, I added the help text to the description, I hope this helps a bit.

Comment only
19 Nov 2012 Romain W

Hi Daniel, would it be possible to have more details about the input?

Comment only
28 May 2013 1.2

Added doctext

Contact us