Arman Akbarian
UNIVERSITY OF BRITISH COLUMBIA
PHYSICS & ASTRONOMY DEPT.

format long
%data file generated using sdtfobin tool
%See http://laplace.physics.ubc.ca/People/arman/files/sdf2bin_files.tar.gz to download
fname='u_r.sdf_12.dat'
f=fopen(fname,'r');
% This is the order of information in the binary file
dim=fread(f,1,'double')
nt=fread(f,1,'double')
nx=fread(f,1,'double')
ny=fread(f,1,'double')
xmin=fread(f,1,'double')
xmax=fread(f,1,'double')
ymin=fread(f,1,'double')
ymax=fread(f,1,'double')
ti = fread(f,1,'double')
t = fread(f,1,'double')

dx = (xmax-xmin)/(nx-1);
dy = (ymax-ymin)/(ny-1);

x=xmin:dx:xmax;
y=ymin:dy:ymax;

z=rand(nx,ny);

% reading 1 level of the data: 

for i=1: ny
  for j=1: nx
    z(j,i)=fread(f,1,'double');
    end
end

z=z';

pcolor(z)
contourf(x,y,z);


last update: Wed May 11, 2016