Version 4 (modified by 11 years ago) ( diff ) | ,
---|
Matlab Scripts
Load BOV File into Matlab
This script will load the data from a bov/dat file pair into matlab
% usage data=load_bov('~/sample_file.bov'); % imagesc(squeeze(sum(data(:,:,:,1),3)) %makes a column density plot along z axis... function data=load_bov(file) fid=fopen(file); [path,name,ext]=fileparts(which(file)); textdata=textscan(fid,'%s',1000); for i=1:3 mx(i)=str2num(textdata{1}{strmatch('DATA_SIZE:',textdata{1})+i}) end components=str2num(textdata{1}{strmatch('DATA_COMPONENTS:',textdata{1})+1}) fclose(fid) file2=[path,'/',textdata{1}{strmatch('DATA_FILE:',textdata{1})+1}] fid=fopen(file2); fread(fid,4,'char'); %fortran unformatted write includes a 4 byte header data=reshape(transpose(reshape(fread(fid,double(mx(1)*mx(2)*mx(3)*components),'float64'), [components,mx(1)*mx(2)*mx(3)])), [mx(1), mx(2), mx(3),components]); fclose(fid);
Create Array of SubPlots
This script allows tilings of subplots with user controlled padding and margins (includes an optional colorbar)
figure(1) clf % All measurements are scaled to window width or height lbuffer=.075; %left margin rbuffer=.075; %right margin tbuffer=.075; %top margin bbuffer=.075; %bottom margin colorbarwidth=.03; %colorbar width - Set to 0 for no colorbar paddingx=.05; % x padding between subplots paddingy=.05; % y padding between subplots nx=4; % number of subplots in x ny=3; % number of subplots in y (not counting colorbar) if (colorbarwidth==0) % no color bar figure_width=(1-lbuffer-rbuffer-(nx-1)*paddingx)/nx; else figure_width=(1-lbuffer-rbuffer-colorbarwidth-(nx)*paddingx)/nx; end figure_height=(1-tbuffer-bbuffer-(ny-1)*paddingy)/ny; deltax=figure_width+paddingx; deltay=figure_height+paddingy; y=bbuffer; for j=1:ny x=lbuffer; for i=1:nx subplot('position',[x,y,figure_width,figure_height]) %--------------------------------------------------------- %replace this plotting code with your plot routine imagesc(rand(20)) %-------------------------------------------------------- x=x+deltax; end y=y+deltay; end if (colorbarwidth > 0) colorbar('position',[lbuffer+nx*deltax,bbuffer,colorbarwidth,ny*deltay-paddingy]) colormap(gray) end
Note:
See TracWiki
for help on using the wiki.