MATLAB Plugins#
The MATLAB helpers read Tecplot data written by tec2mat and
plot unstructured surface zones. Add the plugins/matlab folder to your
MATLAB path to use them.
export MATLABPATH=/path/to/share/tecio/plugins/matlab
- matlab.tecmat2struct(d)#
Reshape a loaded tec2mat .mat struct into a struct array of zones with dataset variables accessible by name.
tec2mat outputs (info, zone_1, zone_2, …) and variables by position (var_1, var_2, …) because valid Tecplot variable names can include characters that are not valid MATLAB identifiers (e.g. “X [ft]”). When the variable names are known to be valid identifiers, this function lets you reformat the structures such that variables can be accessed by name, e.g. plot(zones(1).x, zones(1).pressure) instead of plot(zone_1.var_1, zone_1.var_3).
- Call:
zones = tecmat2struct(d)
- Parameters:
d – struct returned by load() on a tec2mat .mat file, i.e. the struct has fields info, zone_1, zone_2, …
- Returns:
zones –
- A 1 x info.num_zones struct array with identical fields in every
element, so zones(i) and [zones.<varname>] both work. Fields:
.title, .zone_type, .solution_time, .strand_id .I, .J, .K ordered zones; [] for FE zones .num_nodes, .num_elements FE zones; [] for ordered zones .node_map FE zones (resolved through node_map_shared_from if the zone shares connectivity); [] otherwise .face_neighbor_mode, .num_face_connections, .face_connections FE zones with face-neighbor data; '' / [] / [] otherwise .<variable name> one field per dataset variable whose real name is a valid MATLAB identifier (see isvarname). Passive in a zone -> []. Shared -> resolved to the source zone's data, so every zones(i) is self-contained.
Notes
A variable name that is not a valid MATLAB identifier is skipped with a warning; it remains accessible the original way, via zone_<n>.var_<k> and info.var_names{k}.
Shared variables/connectivity are branched (copied from referenced zone’s data into every zone that shares it). This can create large memory usage for files whose zones heavily share a static grid across many time steps.
Example
d = load(‘flow.mat’); zones = tecmat2struct(d); plot(zones(1).x, zones(1).pressure);
- matlab.contourfe(dim, x, y, z, c, node_map, varargin)#
Filled patch contour for unstructured 2D/3D surface zones
- Call:
h = contourfe(dim, x, y, z, c, node_map, …)
- Parameters:
dim – 2 or 3
x,y[,z] – nodal coordinate column vectors (Nx1)
c – contour values; either nodal (Nx1) or cell-centered (Mcells x 1)
node_map – M x K integer matrix of node indices per cell (K=3 or 4)
varargin – name-value pairs forwarded to patch (e.g. ‘EdgeColor’,’none’)
- Returns:
f – handle to the patch object
Notes
If c is nodal, uses ‘FaceVertexCData’ with ‘FaceColor’=’interp’
If c is cell-centered, uses ‘CData’ per-face with ‘FaceColor’=’flat’
For dim==3, z must be provided and plotting uses 3D patch (viewable with lighting)
node_map may contain NaNs for unequal-sided cells; those faces are handled