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
else
% call the function to operate on it * see footnote

end
%% footnote:

fileTARGET = '/Users/.../monthly';
saveTARGET ='/Users/.../figuresSAVE'
% Do the regular stuff
cd(fileTARGET)
% Do the regular stuff: train
fileLIST = dir;
N = length(fileLIST); % fileLIST.name
fn = fileLIST(4).name;
% fn='asdf.ext';
disp(fn)
trainME(fn) % train the network: takes data and trains
%save the figures here
cd(saveTARGET);
% 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])
end
end

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!
Do:

[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...

 Do
 sudo pico /etc/hosts

enter: into the file
 127.0.0.1 facebook.com

 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 (http://www.macports.org/) 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!
http://porticus.alittledrop.com/index.html
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. (http://www.macports.org/install.php or google macport kile)
  • do sudo port install kile
    BOOM
  • It will install all the dependencies and kile itself.  

Read setting path after installing macports:
http://usefulcodes.blogspot.com/2011/05/kile-on-mac.html