Friday, November 28, 2008

Unique data and shuffle data problem in matlab



I had array of data with repeated values...
So, had to get non-repetitive arrays.
This could be done by :
b = unique(data);

for more one can read help unique. This is very useful function.

Moreover, I had to shuffle the data so that they are not perfectly aligned:
I found the function shuffle:

function x = shuffle(x)
%SHUFFLE Shuffle an array of values.
% x = shuffle(x) shuffles the vector x in random order.
% Since this function changes the vector x,
% it creates a copy of it.
n = length(x);
disp n
for index = 1:n
% a random number between i and n
r = index + floor((n-index+1) * rand());
% swap elements index and r
x([index r]) = x([r index]);
end

Surprisingly, it worked for whole matrix.
:)
Happy Friday!!!

Friday, November 14, 2008

Time Delayed execution of function in Javascript

I had complained about re-directing my site by some un-known ghosts.
I have created a simple function which stops it from re-direction but also gives enough time to load the contents...
<script>
window.setTimeout('window.stop()',3000);
</script>
Reference:
http://www.howtocreate.co.uk/tutorials/javascript/timers

Wednesday, September 24, 2008

Blog Restored!

It was deleted, I am back again for the same theme and contexts.

Please stay tuned, or visit:
http://webloggerdai.blogspot.com/

Thursday, September 4, 2008

Windows key preference for matlab

Not so friendly keys for linux.
Don't wanna MEMO more shortcuts for linux.
So, set the preference of key choice to matlab.

Then instead of ctrl+/ press ctrl+r and then uncomment by ctrl+t.
Not only that...
Even cut paste is easier then.
Enjoying it.

Monday, September 1, 2008

Not starting with numerical name

the name to me was fine:
23aug3PM.ext

for given project. So that I can nag it anytime.
But, well, when I try to run it from the command window: it would not run.
Deniz came to my rescue.

Suggestion: not start name with num. Start with alphabet. You can put the num at the end.

:)

Yea, it works!

Tuesday, August 26, 2008

How to make Matlab help feature open external browser

How to make Matlab help feature open external browser?
This is interesting problem and depends upon the system.

And, this is quite easy too!

simply type:
help docopt

you can see alot of details there.

In my case, I use UBUNTU, so as directed by the help file, I modified the "line 52".

52 doccmd = 'mozilla';
That solves the problem, however, I did run 'mozilla' in terminal to make sure that it works.

:)

Easy!

Friday, August 22, 2008

How to delete ASV files: autosave files in MATLAB

I used to have a lot of asv files by the end of the day. While they can efficiently save your work as a back up, having them all over is a pain.
So, I had to manually delete them. One by one. That is another pain.
I came across the fact that they can automatically be deleted.
See figure:
Go to File menu>Prefererences>select autosave and select "Automatically delete auto save files.
Apply and OK.

nice! no more junks!

Getting Started with MATLAB: A Quick Introduction for Scientists and EngineersMATLAB for Engineers (2nd Edition)Matlab: A Practical Introduction to Programming and Problem Solving, Second Edition 

Friday, August 15, 2008

Kill Firefox in Ubuntu

I have been using Ubuntu in Dell Inspiron 6400. Actually, I had installed last year. But unable to use it nicely, because of two reasons. I had no wireless internet available in Ubuntu: in-compatible hardwares and the other was that I had no success in installing Matlab in it.
Now after installing the Matlab successfully and having updated it to Ubuntu 8.x, I can see its inherent beauty.
Actually, this is my second day in Linux environment without the glimpse of the Vista.

I am glad with this...
So, I thought, I should post some of my experiences.


My Ubuntu Experiences: Part x


Today: I got into trouble with the message:
Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

Hmm?

In the case of Vista,( or MS OS) I could go to task manager and kill it. So how can I kill it?

Googled it and found the solution:
http://brainstorm.ubuntu.com/idea/8958/
Stated:
open a terminal and type "killall firefox" and then proceed with "killall children"
I did it, wow! It works.

Friday, August 8, 2008

Run Matlab with full path...

After bit of wrestling, I could finally figure out how to run matlab.

Phew!!!
My problem was that I had skipped the installation of the symbolic link
so, need to run:

/home/bloggerDai/matlab/bin/matlab

:(

long command.

I need to learn how to install the symbolic link, as I can see it is straight forward with su privileges.

Going back to ubuntu to wrestle for that ...

Sunday, June 29, 2008

Watching the whole emipire falling down

You can start with nice tools and build up an empire.
What if after the empire was being built and at final moment you realized that the whole land did not belong to you?

For the permanent peace, you must watch the empire falling down.

Coding Horrors are the description as told by the eye witness of such falling empire.
It is amazing to see that the whole scenario become a nice memorable event.

If you did not learn from the failure, you are not an intelligent animal!

Friday, June 27, 2008

Show me the space!

x = (0.01:.01:1);
y = (0.01:.01:1);


size = length(x);

for i = 1:size
for j = 1:size


...
:)
C:\academy\me2008\TRY11

Model=[Model1, Model2, Model3, Model4, Model5, Model6, Model7, Model8];
QQ=0;
for k = 1:N
QQ=QQ+(Di(k)-Model(k)).^2;
end
z(i,j) = -(QQ)./(2*sigma.^2);
end
end
% logL=(-N/2)*log(QQ);




[X,Y] = meshgrid(x,y);

Z = griddata(x,y,z,X,Y,'cubic');


meshc(X,Y,Z) %
colormap hsv

surfc(X,Y,Z)

Thursday, June 26, 2008

Multiple Codes and similar codes

Hmm.. this one is sneaky!

Time after time, I have managed to make 20 different files of the codes during the test run.
Everyone of them runs.

Now the problem is which one is the best one.
...
Which one was the best one that worked nicely?
I am asking to myself...
Why did I have to run immediately after getting the program run?
I should have noted the program.

Now I will need to go through the lines and check!
:(

Tuesday, June 24, 2008

Stopping Criteria

try = ooo;
test = ooo;

break =20;

%%%after MCMC

if i == break
a =isequal(test,ooo);
if a == 0
break
else
break = break+5
end
end

Monday, June 23, 2008

What if it explores in-correctly?

Whenever you are looking into the probability space, give me some reasoning to verify or to convince me that you are looking into the space which is beautiful.
By beautiful space, I mean the space which is useful to explore.

In this perspective, my algorithm was looking into the space which was contracted in some random way.

In order to fix it, i needed to change by explore strategy:


notOK = 1;
while (notOK)
Try(i).A = Obj.A + step*(2*rand-1);
% Try(i).A = Obj.A + step*randn; % not quite gaussian :)
if Try(i).A > 0
notOK = 0;
end
end
notOK = 1;
while (notOK)
Try(i).B = Obj.B + step*(2*rand-1);
if Try(i).B > 0
notOK = 0;
end
end
notOK = 1;
while (notOK)
Try(i).C = Obj.C + step*(2*rand-1);
if Try(i).C > 0
notOK = 0;
end
end

Friday, June 20, 2008

"Horrible Habits"

Donot call main function like I do!
run('C:\academy\... ... ... \try7\2runs.*')

Instead, Modify the main file.

What I can do is I can add loop inside the main and have it running ; instead of calling from another file which has loop.

Save the version1, version2 and so on.

%%%%%%%%%%%%%%%%%

The problem was identified since the loop was running by pressing the ctrl+enter key but was not working whenever was called in the command window.

Stopping Criteria

Follow up from yesterday's NS code.

Check at the 3500th iteration if it is above the desired/actual/computed/pleasant number.

if yes,
break
no?

go to hell!!!
(I mean to 10000th iteration)

ha ha!

%%%%%%%%%%%%%%%%%%%

if nest = = 3500
[x,y,z] = Results(Samples, nest, logZ);
if x>0.1
break
end
end

Thursday, June 19, 2008

Hurray!

I will be online, coding.

So, lets dump some ideas here.

Everything will be personal. And I will not leave a single hint on who am I.

Wednesday, June 18, 2008

Imaginary standard deviation: Discussion with Deniz: Because even after the convergence has been achieved, the program keeps adding small logZ (whic

Imaginary standard deviation:

Discussion with Deniz:

Because even after the convergence has been achieved, the program keeps adding small logZ (which should not be the case).

That means:


[w_array] = Results1(Samples, nest, logZ);
mean(x) = 0.33611 stdev(x) = 0+1.6919e-006i
mean(y) = 0.34601 stdev(y) = 0+1.7417e-006i
mean(z) = 0.33582 stdev(z) = 0+1.6904e-006i
>> sum(w_array)

ans =

1.0000

>> format long
>> ans

ans =

1.000000000025338


Which is the problem, as this can result into imaginary stdev!!!


One of the approach to solve this problem would be to have a stopping criterion in the algorithm. This can be something like this:

If logZ(i+1)-logZ(i) < = eps

STOP!!!

Lets see!

Tuesday, April 1, 2008

How to create movie

countme=1;

figure;

for i = 1:n
x = Obj(i).x;
y = Obj(i).y;
plot(x,y,'o');
hold on
axis([-2 2 0 2]);

end
hold off
% ***************************************
% print(gcf, '-djpeg',['nnn',num2str(nest)])% this saves the pictures in jpeg format, with numbers in filename.
% **************************************
h=get(0,'CurrentFigure');
F(countme)=getframe(h);
F(countme)=getframe(gcf);
% **********************************
% save(['C:\academy\knuth\lighthouse\myWS', num2str(countme)]) % saves the work space without completion of loop
% ***********************************
countme=countme+1;
end

movie(F); % This is not working to create movie in my case.
% movie2avi(F,'movie');

Wednesday, March 12, 2008

Matlab Picture

print(gcf, '-djpeg',['nnn',num2str(nest)])% this saves the pictures in jpeg format, with numbers in filename.
(in my case nest runs in loop in the lighthouse problem, so will get the names of the loop)

Friday, February 15, 2008

How to hide the nav bar at the top in blogspot

Paste the following code just after the Header starts (after the head tag)

Date: 15 Feb 2008
Updated by: dai
----------------------------------------------- */


.navbar {
display:none;
}
* {
margin: 0;
padding: 0;
}


ब्लॉगर टेम्पलेट स्टाइल
नेम: रौंदेर्स ३
डिजाइनर: डगलस बोव्मन
उरल: व्व्व.स्तोप्देसिग्न.कॉम
Date: 27 Feb 2004
Updated by: Blogger Team
----------------------------------------------- */




.navbar {
display:none;
}
* {
margin: 0;
padding: 0;
}
-->