Thursday, March 31, 2011

Automating file operations in matlab excluding the directories

Automating the work in directory with tree structure is fun. You can leave it overnight and get the output the next day.
However, hidden files/folders can be troublesome.
Specially these:
and .DS_Store (in mac)
or other set up stuffs

for jj = 1:length(fileList)
if fileList(jj).isdir
% do not operate the file
% call the function to operate on it * see footnote

%% footnote:

fileTARGET = '/Users/.../monthly';
saveTARGET ='/Users/.../figuresSAVE'
% Do the regular stuff
% Do the regular stuff: train
fileLIST = dir;
N = length(fileLIST); %
fn = fileLIST(4).name;
% fn='asdf.ext';
trainME(fn) % train the network: takes data and trains
%save the figures here
% savefile = fn;
save('savetrained.mat', '-mat', 'net'); % save the network... JIC
% cd(fileTARGET);
% cd(saveTARGET); instead, we can feed the folder structure into function making the code more general see below:
saveFIG(fileLIST, fileTARGET, saveTARGET, net); 

% save the plotted figures; as the target directories and save target directories are taken as input, it is more general for its usages


I have also found a better way of working on it:

for jj = 1:length(fileLIST)
fn = fileLIST(jj).name;
[pathstr, name, ext] = fileparts(fn);
if strcmp(ext, '.hdf')
% do not operate the file
% else
disp(['Working on : ', fn])

Monday, March 21, 2011

Click and get the co-ordinates of a plot

Getting the co-ordinates of the desired points in matlab plot can be tricky.
ginput useful!

[x,y] = ginput(n)

and hit enter/spacebar to exit if no n is specified.

Thursday, March 10, 2011

How to block website in MacOS

Say wanted to block facebook...

 sudo pico /etc/hosts

enter: into the file

 and save out ctrl+O; ctrl+x

refresh cache
 sudo dscacheutil -flushcache

Friday, March 4, 2011

Thursday, March 3, 2011

Using MacPorts and Porticus

Macports ( is awesome, except that it installed stuffs in wierd places so that I could not run netcdf properly. Now I have done it manually.
Came across the GUI for it:

Looks good!
Except that it is also unable to update stuffs!

Wednesday, March 2, 2011

Installing Kile on Mac

 I find it easy to use macport.

  • Simply go to macport site to download the disk image (dmg) for macport. ( or google macport kile)
  • do sudo port install kile
  • It will install all the dependencies and kile itself.  

Read setting path after installing macports: