Wednesday, November 9, 2011

Load matfiles


Load the required files from a directory


clc
matDIR = '/.../matfiles/';
% workDIR = '/Volumes/3TB/.../AquaLand20/';
files = dir(matDIR);

% Remove the '.DS_Store' from the list
if strcmp(files(3).name, '.DS_Store')
files(3) = [];
end


% count =3;
row = 1;
for count= 3:length(files)

FNamebase=files(count).name;

inDIR =[matDIR, FNamebase];

if exist(inDIR)>0

load([inDIR ]);
time(row) = toc;
iter(row) = j-1;

disp(['Loaded! ',FNamebase]);

row = row+1
end
end

Tuesday, November 8, 2011

Using Imagemagick shell command to crop figures

How to crop figure and save as png.
This is useful for cropping similar figures located in a folder.

Copy the code, save as cropfig.sh
and then run the cropfig.sh in your terminal...

#!/bin/bash
width=1800;
height=1680;
x_offset=502;
y_offset=40;
filelist=`ls | grep '.png'`
for image_file in $filelist
do
preextensionfilename=`convert $image_file -format "%t" info:`
convert $image_file -crop ${width}x${height}+${x_offset}+${y_offset} \
${preextensionfilename}_${width}x${height}.png
done


Thursday, November 3, 2011

Remove the .DS_Store from the file list

Sometimes, working on the filelist is troublesome because of the .DS_Store

WhereAqua = pwd;

files = dir(WhereAqua);

% Remove the '.DS_Store' from the list
if strcmp(files(3).name, '.DS_Store')
files(3) = []
end


There is another way too!
fileLIST = dir;
N = length(fileLIST); % fileLIST.name
 status = mkdir(pwd, 'hdfClass'); 

if exist('.DS_Store','file')
! rm .DS_Store
fn =  fileLIST(4).name;
else
fn =  fileLIST(3).name;  

-->