Monday, November 29, 2010

Can't create index output file in texnic center

I was beating my day because the index was not being printed on the report.
Later, after a good number of search(es),  I found that this is interesting feature of MikTex 2.9

The problem was solved by changing %bm to %tm in the MakeIndex option.

Here is what I did:
Go to build > Define Output Profiles (Alt+F7)
Change %bm to %tm in the MakeIndex option.
Probably same thing needs to happen with Bibtex (if problem persists).

I am really glad that you are finding it useful. Happy Texing!

Saturday, November 27, 2010

Entropy Plot for a fair coin toss

Entropy Plot for a fair coin toss

(Yes png as pdflatex does not take eps or pdf format.)

clear all
close all
p = 0.0:0.0001:1
entropy = -(p.*log2(p))-((1-p).*log2(1-p)); % in bits try logp to see in nats
h = plot(p,entropy);
axis tight;
mypretty(h,'Probability','Entropy (bits)','Entropy versus probability for a coin toss')
set(gca, 'LooseInset', [0,0,0,0]);
saveas(h, 'entropy_parabola.png')

Friday, November 26, 2010

Thursday, November 25, 2010

Matlab codes in Latex

Use the package (mcode.sty) from:
in the "header"

Here is what I did:

This creates a box, pushes everything inside the box (ugly though) and forces next item to new page
\lstinputlisting[label=lst:run_main,breaklines=true, caption={\mcode{run_main.m}}]{G:/academy/random-s-circle/jan14-refine/run_main.m}

Wednesday, November 24, 2010

Playing with saved figure to decorate

playing with the saved figure

% uiopen('intensity_compared5MoG.fig',1)
handle = set(gca);
axis([29 71 29 71])
line([29 71], [50 50],'LineWidth',1,'Color','yellow')
line([50 50],[29 71],'LineWidth',1,'Color','yellow')
handle = gcf;
% dummy = mypretty(handle,'Position of the center of the sensor (cm)','Intensity (LEGO Units)',... 'Intensity measurement compared for 5 MoG')
% hh = legend('prediction1','prediction2','prediction3','prediction4','data1','data2','data3','data4',2);
% dummy = set(gca,'LineWidth',2,'MarkerSize',8)

cd 'ssf-figures'
% saveas('')
% filename = 'intensity_compared5MoG'
filename = 'SSF_5MOG_zoomed'

% pause
% close
% cd 'ssf-run-home'

Wednesday, October 13, 2010

Creating movie in matlab

Creating movie in matlab is not so fun. I would suggest saving each picture and using gimp to create the gif instead.

% Script file firstmovie.

% Graphs of y = sin(kx) over the interval [0, pi],
% where k = 1, 2, 3, 4, 5.

m = moviein(5);
x = 0:pi/100:pi;
for i=1:5
h1_line = plot(x,sin(i*x));
title('Sine functions sin(kx), k = 1, 2, 3, 4, 5')
h = get(gca,'Title');
k = num2str(i);
if i > 1
s = strcat('sin(',k,'x)');
s = 'sin(x)';
h = get(gca,'ylabel');
m(:,i) = getframe;
This was taken from

Thursday, September 30, 2010

Writing Equations in Blogspot Blogs

I can write equations in blogspot using latex command: $1+x^2$.

The Function \[\frac{sin(x)}{x}\] .

Since I did not include the p tag to it, it was not interpreted.

However, If I add the p html-tag, it will appear as:

The Function \[\frac{sin(x)}{x}\] .

One can also type the latex and paste in the blog posts...
Just remember to put
<script type="text/javascript" src=""></script>

in the post
I am not sure how to change the dark background...

Tuesday, August 24, 2010

Tex on matlab figure axis labels

It is highly desirable to have tex characters into matlab figures. It is not one to one. But works!
The following is very good resource:

xlabel(Number of Samples (\textit{N}))
??? xlabel(Number of Samples (\textit{N}))
Error: Unexpected MATLAB expression.

>> xlabel(Number of Samples (textit{N}))
??? xlabel(Number of Samples (textit{N}))
Error: Unexpected MATLAB expression.

>> xlabel(Number of Samples (N))
??? xlabel(Number of Samples (N))
Error: Unexpected MATLAB expression.

>> xlabel('Number of Samples (textit{N})')
>> xlabel('Number of Samples (\textit{N})')
Warning: Unable to interpret TeX string
>> xlabel('Number of Samples ('\textit{N},')')
??? Undefined function or variable 'N'.

>> xlabel('Number of Samples ('\textit{'N'},')')
??? Undefined variable "textit" or class

>> xlabel('Number of Samples {\it{N}')
Warning: incomplete command in TeX text
'Number of Samples {\it{N}'
>> xlabel('Number of Samples {\itN}')

Thursday, April 15, 2010

save figure as per iteration in matlab

I wanted to save the files in jpeg format as I go...
The following helped me to save it in myplot1.jpeg format.

saveas(gcf,['myplot', num2str(iteration)], 'jpeg')

print(gcf, '-djpeg',['Entropy_map_',num2str(j)])

Wednesday, April 14, 2010

Sampling within the range

Explore and get me values that I want within the range

close all
clear all
m = 23;
n = 34;
jumpSTEP = 11;
broken = 1;
playX = [-3:0.1:3];
playY = [-3:0.1:3];
reject = 1;
for jj = 1:1000
    notOK = 1;
    while notOK
        m = m + ceil(jumpSTEP*rand);
        n = n + ceil(jumpSTEP*rand);
        m = rem(m,length(playX));
        n = rem(n,length(playY));
        saveM(jj) = m;
        saveN(jj) = n;
        if m<1
            reject = reject+1;
        if n<1
            reject = reject+1;
        if m>1
            notOK =0;
        if n>1
            notOK =0;

plot([1:1000],saveM, 'or');
hold on
plot([1:1000],saveN, 'ok');
plot([1:1000], 1, [1:1000], length(playX) );

Saturday, April 10, 2010

Unix commands inside matlab: cp, mkdir, rm etc

Implementing the unix commands in the matlab is so easy.
I wanted to automate the file organizing process.
A very simple code combined with is going to work great!
unix('mkdir back') % make directory for backup

unix('cp *.m back') % copy to it or may be more would be better
unix('cp  114.mat back') % copy the file to be saved
unix('cp *.jpg back') % copy the figure to be saved
unix('rm *.*') % delete all files :) not directory

Sunday, April 4, 2010

Nested Function inside function

I had never done a nested function inside another.
It helps to avoid the necessity of having more files as m function. Useful when the function is only called by the same file.
However, the main file itself needs to be saved as function instead of script.

function test
a = 1;
b = 2;
test1 = istested(a,b)

function answer = istested(a,b)
a = a+1;
answer = isequal(a,b);

Wednesday, March 24, 2010

recursive action into folders

I wanted to do mcc to all the files inside the folder... you know automate it.
This one does it!

clear all
% Read directory names
dirLIST = dir

% get number of directories
N = length(dirLIST)

% Loop through the directories
% Skip the first two..
for n = 3:N

    thisDIR = dirLIST(n).name;

         disp(['Working on ' thisDIR]);
        mcc -m run_me_deAR.m




Monday, March 22, 2010

automated mcc to list of files (fail!)

this did not work

clear all
% Read directory names
LISTitems = dir;

% get number of directories
N = length(LISTitems);

% Loop through the directories
% Skip the first two..
for n = 3:N

   doTHIS= LISTitems(n).name
   mcc -m doTHIS % does not work!

% cd('..');
% pwd

Saturday, March 20, 2010

automated direcotry listing in matlab

Very simple program for listing the file names as I had to monitor the files from many folders for repetitive works.

clear all
% Read directory names
dirLIST = ls;

% get number of directories
N = length(dirLIST)

% Loop through the directories
% Skip the first two..
for n = 3:N

    % Close all open figures
%     close all;
    thisDIR = dirLIST(n,:);

    if isempty(strfind(thisDIR,'.'))
%         home

cd ..

Thursday, March 18, 2010

Wednesday, March 17, 2010

Upgrading Texnic Center

Upgrading Texnic Center can be tricky.

When I updated it from previous version, I came across problems.
The MikTex was updated from 2.5 to 2.8. And, I ignorantly had uninstalled the 2.5 version.

I realized that changing 2.5 to 2.8 in the output section worked!!

Instead of this:
C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exeI wanted to use the Yap, it is still not working.
C:\Program Files\MiKTeX 2.8\miktex\bin

Automated Code execution in different folders as per iteration and value

I wanted to automate the code execution in different folder as per iteration.
 This works!

perc = 0.05:0.2:1;
for folder = 1:length(perc)
    percent = perc(folder);
    r = sqrt(percent/pi)*4;
        case 1
            cd 1
%             pause
            cd ..
        case 2
            cd 2
%             pause
            cd ..
% %         case 3
% %             cd 3
% %             run_me_deAR(r)
% %             pwd
% % %             pause
% %             cd ..
% %         case 4
% %             cd 4
% %             run_me_deAR(r)
% %             pwd
% % %             pause
% %             cd ..
% %         case 5
% %             cd 5
% %            run_me_deAR(r)
% %             pwd
% % %             pause
% %             cd ..
% %           

Tuesday, March 16, 2010

Check if the data is already in there

I wanted to test if my new coming data was already contained in the set.
This is very easy!

test = rand(1,23);
A = test(5);
B = test-A;
BB = B(B==0);
if length(BB)>0
    disp('has it!!')
% another attempt
test = ceil(10*rand(1,10));
doit = 1;
jj =1
while doit
    A = ceil(10*rand);
    B = test-A;
    BB = B(B==0);
    if length(BB)>0
%         A = ceil(10*rand);
%         B = test-A;
%         BB = B(B==0);
        disp('test done!!')
        doit = 0;

Monday, March 15, 2010

Load the matfiles as per iteration

I save the mat files as per iteration.
 This is handy just in case your program is killed.
For the post analysis, I wrote the following to load the .mat file/data.
It loads 1.mat...

for i = 1:18
    filename = [num2str(i)];
    load([filename '.mat'])
    % do something useful

Sunday, February 28, 2010

Kile on Mac and troubles

One down...

[ViewDVI] finished with exit status 127

$ kdvi test.tex
The program 'kdvi' is currently not installed.  You can install it by typing:
sudo apt-get install kdvi
bash: kdvi: command not found

sudo port -f activate dbus
sudo port install kile

Wednesday, January 20, 2010

Matlab Keyboard Compatible with Windows Keyboard

Play with Matlab compatible to Windows keyboard.
Shortcuts not working?
Check with preferences...

Friday, January 8, 2010

Setting Path Straight in Matlab

Setting Correct Path in Matlab can be tricky as your program evolves to have similar folder structures and filenames.
Just learned how to set the path from Shortcut... wanted to share.

The following code helped me to set the path before I start the functions running...

mypath = pwd

mypath =


>> path(path,mypath)

Having a shortcut shall not hurt!