Friday, February 6, 2015

Perceptually different colors

Sometimes, you need a plot which compares about 10 different methods. In that case there is a particular need for each line in the plots to look different, here is a neat function:(big thanks to harsh agrawal for finding this)

http://www.mathworks.com/matlabcentral/fileexchange/29702-generate-maximally-perceptually-distinct-colors/content//distinguishable_colors.m

Friday, January 30, 2015

sql stuff

-- Key words case insensitive
-- LIKE arguements case insensitive
-- to be continued..



removing symlink to a dir

rm <dir_name>
# no backslash at the end of the directory name

Friday, September 5, 2014

Script to create in a bash script

Here is a shell script I use to create multiple nohup commands and put them in bash script called scripts1to100.txt. Each nohup command runs a matlab function called  runFunctionWithVariablesAandB which takes a and b as inputs.

for i in {1..100};
 do
let a=(i-1)*100+1;
let b=i*100;
echo nohup matlab -nodisplay -nosplash -r \"runFunctionWithVariablesAandB\($a:$b\)\; exit\;\" \> \/home\/logs\/batch$i.log \& >>scriptsFor1to100.txt;
 done

Once script1to100.txt is ready, you can run it by calling 'bash script1to100.txt'

Note: This particular script launches 100 parallel runs of runFunctionWithVariablesAandB, each with a different set of inputs.

Tuesday, September 2, 2014

Inserting text in visual mode in vim

Steps:

1) Ctrl+v (takes you to visual mode)
2) up/down/left/right arrows to select location for inserting text.
3) Gto select all lines in the file
4) Actual commands for inserting: 'I' takes to insert mode
5) type the text you want to insert. It gets inserted in the first line
6) hit Esc. the inserting done in all the lines you selected.

Friday, August 29, 2014

Comparing strings

strcmp(var,'<string>')

Thursday, August 28, 2014

checking for a field in struct matlab

To check if stuct S has a field called 'fieldName', use:

isfield(S, 'fieldname')