...this is a log of code snippets and useful tips I wrote/found. Should you find any mistakes or have any useful suggestions, please do not hesitate to write to me.
Saturday, November 30, 2013
Tuesday, November 19, 2013
Searching and Replacing strings in vi
:%s/pattern/replace/
if you are searching for a special character( '.', '$' etc), precede it with '\'
Wednesday, October 9, 2013
using nohup
nohup matlab -nodisplay -nosplash -r Script1 > out.txt &
Edit
f you want to run a function with variables, this is how to do it:
nohup matlab -nodisplay -nosplash -r "funcitonabcc(var1,var2,..,varn); exit; " > out.txt &
the text within the double quotes needs to be written just as you would call commands in matlab.
Edit
f you want to run a function with variables, this is how to do it:
nohup matlab -nodisplay -nosplash -r "funcitonabcc(var1,var2,..,varn); exit; " > out.txt &
the text within the double quotes needs to be written just as you would call commands in matlab.
Friday, September 20, 2013
Substringing in matlab
Many functions in matlab let you do various things to strings
strtok(s,delim)
returns the substring before delim
[first,rem]=strtok(s,delim)
first the substring before delim
rem the substring s-first(it includes delim)
strrep(s,'a','b')
replaces a with b in s
strtok(s,delim)
returns the substring before delim
[first,rem]=strtok(s,delim)
first the substring before delim
rem the substring s-first(it includes delim)
strrep(s,'a','b')
replaces a with b in s
Sunday, September 15, 2013
a script for counting images/features
for i in $(ls);
do
cd $i;
imcount=`ls |wc -l`;
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/feature/$i;
for j in $(ls);
do
cd $j;
fcount=`ls|wc -l`;
if [ "$imcount" -ne "$fcount" ]; then
echo $i;
echo $imcount
echo $j;
echo $fcount;
fi
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/feature/$i;
done
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/image;
done
do
cd $i;
imcount=`ls |wc -l`;
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/feature/$i;
for j in $(ls);
do
cd $j;
fcount=`ls|wc -l`;
if [ "$imcount" -ne "$fcount" ]; then
echo $i;
echo $imcount
echo $j;
echo $fcount;
fi
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/feature/$i;
done
cd /home/nchavali/feature_extraction/SUN_source_code_v2/data/ImagenetDataset/image;
done
Some file operations in unix
for i in $(ls); do h=`echo $i|cut -d '_' -f1`; echo $h; done
This lists all the files in the current dir, and ehos a part of their name. thsi h can then be used as a directory location
This lists all the files in the current dir, and ehos a part of their name. thsi h can then be used as a directory location
Wednesday, September 4, 2013
Latex homework Q/A template
\documentclass{article}
\usepackage{lipsum}
\newcounter{question}
\setcounter{question}{0}
\begin{document}
\title{ ECE 5605 Stochastic Signals and Systems, Fall 2013 \\Homework 1}%replace X with the appropriate number
\author{Neelima Chavali \\ PID 905774330 %replace with your name
} %if necessary, replace with your course title
\maketitle
\newcommand\Que[1]{%
\leavevmode\par
\stepcounter{question}
\noindent
\thequestion. Q --- #1\par}
\newcommand\Ans[2][]{%
\leavevmode\par\noindent
{\leftskip1 pt
A. --- \textbf{#1} #2\par}}
\Que{
{2.21} %You can use theorem, exercise, problem, or question here. Modify x.yz to be whatever number you are proving
A die is tossed and the number of dots facing up is noted.\\ (a)Find the probability of the elementary events under the assumption that all faces of
the die are equally likely to be facing up after a toss.
}
\Ans{
The elementary events in this case are the face of the die showing a specific number of dots facing up. The number of elementary events (= 6) is finite. And it is given that all the elementary events are equally likely. Then the classical definiton of probability can be used to derive the probability of the elementary events. There are 6 mutually exclusive elementary outcomes.(1,2,..,6 dots facing up). The attribute A=i dots facing up, i=1,2,..,6 has one elementary event associated with it. $n_{A}=1$ for for all A. Therefore the probability of the elementary events is $n_{A}/n$ = 1/6
}
\end{document}
\Que{Here first question would come}
\Ans{\lipsum[1]\lipsum[1]}
\Que{Here first question would come}
\Ans{\lipsum[1]\lipsum[1]}
\usepackage{lipsum}
\newcounter{question}
\setcounter{question}{0}
\begin{document}
\title{ ECE 5605 Stochastic Signals and Systems, Fall 2013 \\Homework 1}%replace X with the appropriate number
\author{Neelima Chavali \\ PID 905774330 %replace with your name
} %if necessary, replace with your course title
\maketitle
\newcommand\Que[1]{%
\leavevmode\par
\stepcounter{question}
\noindent
\thequestion. Q --- #1\par}
\newcommand\Ans[2][]{%
\leavevmode\par\noindent
{\leftskip1 pt
A. --- \textbf{#1} #2\par}}
\Que{
{2.21} %You can use theorem, exercise, problem, or question here. Modify x.yz to be whatever number you are proving
A die is tossed and the number of dots facing up is noted.\\ (a)Find the probability of the elementary events under the assumption that all faces of
the die are equally likely to be facing up after a toss.
}
\Ans{
The elementary events in this case are the face of the die showing a specific number of dots facing up. The number of elementary events (= 6) is finite. And it is given that all the elementary events are equally likely. Then the classical definiton of probability can be used to derive the probability of the elementary events. There are 6 mutually exclusive elementary outcomes.(1,2,..,6 dots facing up). The attribute A=i dots facing up, i=1,2,..,6 has one elementary event associated with it. $n_{A}=1$ for for all A. Therefore the probability of the elementary events is $n_{A}/n$ = 1/6
}
\end{document}
\Que{Here first question would come}
\Ans{\lipsum[1]\lipsum[1]}
\Que{Here first question would come}
\Ans{\lipsum[1]\lipsum[1]}
Subscribe to:
Posts (Atom)