-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathconvert_zdisp_dat.m
48 lines (40 loc) · 1.33 KB
/
convert_zdisp_dat.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function []=convert_zdisp_dat(ZDISPFILE)
% function []=convert_zdisp_dat(ZDISPFILE)
%
% Convert zdisp.mat -> zdisp.dat so that individual time step data can be read
% instead of needing to read in all time steps at once (and clobbering
% available RAM). zdisp.mat is assumed to exist in the CWD.
%
% INPUTS: ZDISPFILE (string) - full or relative path to zdisp.mat
%
% OUTPUTS: zdisp.dat is saved to the same directory in ZDISPFILE
% All data is float32 with the format:
% NUM_NODES
% NUM_DIMS (Node ID, X, Y, Z displacements)
% NUM_TIMESTEPS
% The rest of the data are the concatenation of NUM_NODES x
% NUM_DIMS x NUM_TIMESTEPS.
%
% EXAMPLE: convert_zdisp_dat('/data/mlp6/zdisp.mat')
%
% Mark Palmeri (mlp6)
% mark.palmeri@duke.edu
% 2009-07-08
ZDISPDAT = regexprep(ZDISPFILE,'zdisp.mat','zdisp.dat');
if(exist(ZDISPFILE,'file') == 0),
error(sprintf('%s does not exist in the CWD.',ZDISPFILE));
else,
load(ZDISPFILE);
end;
fid=fopen(ZDISPDAT,'w');
numnodes = size(zdisp,1);
numdims = size(zdisp,2);
numtimesteps = size(zdisp,3);
fwrite(fid,numnodes,'float32');
fwrite(fid,numdims,'float32');
fwrite(fid,numtimesteps,'float32');
for t=1:numtimesteps,
fwrite(fid,squeeze(zdisp(:,:,t)),'float32');
end;
fclose(fid);
disp(sprintf('File Created: %s',ZDISPDAT));