read and write CAD Data files using matlab (DX format)

バージョン 1.0.0.0 (4.75 KB) 作成者: Evan
read and write CAD data in a DX format
ダウンロード: 1.1K
更新 2013/8/5

ライセンスの表示

CAD data files in a DX format are a straightforward and useful way to interpret and communicate 3D data among programs. This pair of programs reads and writes these files to allow users to interface matlab code with such programs.

-- example usage: output a spherical gradient 10 angstroms in radius --

[X Y Z] = meshgrid(-10:10); % make a 3D gradient
input.densityMatrix = ((X.^2 + Y.^2 + Z.^2).^0.5); % construct 3D space
isosurface(input.densityMatrix); % plot in matlab
mat2dx(input); % output as DX file

-- example usage: normalize DX output --

DXdata = dx2mat('DXfile.dx'); % interpret DX data
mat3D = DXdata.densityMatrix; % make name convenient
maxValue = max(max(max(mat3D))); % find max value
minValue = min(min(min(mat3D))); % find min value
valueRange = maxValue - minValue; % find range of data
DXdata.densityMatrix = (mat3D-minValue)/valueRange; % normalize and save
DXdata.outfile = 'DXfile_normaized.dx'; % rename output
mat2dx(DXdata); % write to DX file

%% -- mat2dx.m --
%
% this function outputs a DX file for viewing in programs such as VMD or PyMOL. It uses
% six inputs to function properly (subvariables of "DXdata"). While only
% one is necessary (the 3D matrix called "densityMatrix"), the others shape
% and position the 3D matrix in space. A minimum point and a voxel length
% are required to do this. The minimum point is recorded as the "minX"
% "minY" and "minZ" variables.
% As of July 2012, file output format is as defined on
% http://www.poissonboltzmann.org/file-formats/mesh-and-data-formats/opendx-scalar-data

%% -- dx2mat.m --
%
% this function reads in a DX file and translates it into a 3D matrix in
% matlab. DX files are file formats for storing 3D data in plaintext, and
% they are readable by PyMOL and VMD. One inputs the DX file path, and the
% program outputs a structure with all the information about the DX

引用

Evan (2024). read and write CAD Data files using matlab (DX format) (https://www.mathworks.com/matlabcentral/fileexchange/42958-read-and-write-cad-data-files-using-matlab-dx-format), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2010a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersModel Import についてさらに検索

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.0.0.0