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]);

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