Thursday, July 29, 2010

~ Innovation exploitation

Salam alaik,

Prediction or extrapolation offers the ultimate test of the information-content one possesses.
This process is most evident in toddlers, trying to explore the world around learning to walk n talk.
The ability that the Creator; Allah, has bestowed upon them is to be curious enough to learn_by_making_mistakes.
In other words, this ability allows one to compare an expected_out_come against actual _out_come.

Herez a make up example to explain: a child has some cool toy with black n white colors on it which he likes. Now he looks at the black n white colored stove & ponders, "hmmm... this (stove) looks cool, must be playable." Poor child burns his hand but learns a great deal - albeit the hard way - that all black n white stuff ain't so cool.
There was an error in the prediction - a great deal in this case - but lesson learnt was lasting nonetheless.


A less forgiving case is that of exercise questions at the end of chapters, written by seasoned authors.
A student uses the information given in the chapter to solve the exercise questions (which are not plug_this_formula_n_get_answer sort), only to find out that he couldn't quite get hold of it.
He goes back, reads up the same info over again from the perspective of the question, & try giving it another shot based on that info.
He, actually, is predicting & then improving on his grip about the subject from his initial error.

Same is the concept of Kalman filtering, i'm into these days.


Its a probability-based digital filter capable of filtering 'white noise', using its own error-information.

Here, the difference between a prediction and reality is called "innovation", & learning is all about exploiting that "innovation".


more on it laterz sometime.. inshAllah
~*~*~*~*~~*~*~*~*~

Friday, July 23, 2010

~ Soaring the Simulation

Salam alaik,

Thinking Vectors & Matrices.. its either my way or MATLAB's way..

On a semi-sarcastic side note though, Guys having C or Java background write a MATLAB script just as they'd do that in C, i.e. using loops.
MATLAB is all about vectors & matrices.. so loops could be avoided consideably.
To wit - Consider this simple example;

Lets say we've got two vectors, like so;

a = [1 2 3]' and, b = [4 5 6]'

Now if we wantna take the dot product in C, we would write something like this for loop in C;

c[i] = a[i]*b[i];

While in MATLAB its simply;

c = a'*b; %(a Transposed x b),

So, in essence it does the looping for us.. clean & simple.

Coming back to Simulations..
A cool tool for writing communication system simulations; MATLAB, offers two approaches to do so;

1. MATLAB scripting language.
2. Simulink blocksets.


The former is recommended for the proof_of_concept development usually required in academic & research projects, while the latter is for rapid prototyping in time-constrained industrial projects.
I, for one, usually use the first approach, as my work involves research & development.
The key to make a script time-efficient is to;

a. Think in vectors and matrices.
b. Avoid unnecessary loops here & there.
c. Initialize large vectors and matrices before use.

With these simple tips one could make life quite easy.

Happy scripting...

But wait..
Sometimes the curves you get from MATLAB simulations aren't smooth enough, even after several 100th of runs. I usually smooth them out using:

sgolayfilt(your_variable, m, F)
where m=2,F=21.

Result: cool looking curves, at the expense of one additional line in simulation section of your paper.

Furthermore, I also change the font size & width of the curves using;

h = plot(my_x, my_y); hold on; grid on;
set(h, 'linewidth', 3);
set(get(h, 'parent'), 'fontsize', 14);

Result: .. even cooler 
;o)

~*~*~*~*~~*~*~*~*~

Wednesday, July 21, 2010

~ Casting out the Colors

Salam alaik,

MATLAB generates cool looking colored ps-files.
Unfortunately thoguh, most of the conferences & periodicals ask for gray scale images instead.
It gives you a big pain_in_the_neck tryna find suitable colors that could be distinguished at gray-scale level, esp in cases when markers don't serve the purpose well enough.

So..
I've discovered a simple Color to gray scale trick.
How to get around it is a little more tricky.
& by the end of the toil u'll get MATLAB generated PS-files, by editing the ps file directly.

First off, search for lines similar to;

/c8 { 1.00000 0.000000 0.000000 sr} bdef

Now lets dissect down this piece by piece..

/c8: According to my calculations '/c' means color here and '8' is numbering that may vary.

{1.00000 0.000000 0.000000 sr}: The RGB values; all values should be same & less than one for grey-scale. Note that all 'zeros' mean black, and all 'ones' mean white. Darker values are harder to distinguish, so I suggest giving more gap in values chosen between 0-0.5. While, less gaps can be afforded for values between 0.5-1.0.

That little doo-dad will clear the remainder of the picture. Like so;
Here is an example of a color image;


Now ,we require 6 gray-scale values. I used [0 0.3 0.55 0.65 0.75 0.85], & VOILA!
Here is the result;


aint that a neat trick right there?
It actually isn't much of a trick..
see if u could come up with more trix.

~*~*~*~*~~*~*~*~*~

Saturday, July 17, 2010

~ Fiddling with Figures

Salam alaik,

People've got an awesome practice of saving figures in the simulation script just after results are finalized.

Its a jolly good habit for all i can tell, since it pretty much prevents a lot of future headache.

No rocket science there..
The function to save a MATLAB figure file "saveas"; can save in several formats including fig (matlab figure), bmp (bitmap - though not recommended), ai (adobe illustrator), psc2 (colored post-script - recommended for latex), so on n so forth.

Fig files are useful in another sense, i.e., the data is automatically secured with it. n i'll show you in a minute -inshAllah- how data could be extracted from the saved fig files;
  1. Open the saved .fig file using open function. e.g., open abc.fig
  2. Use gcf to get the current figure pointer/handler and save it in a variable, e.g., h = gcf
  3. Use get command to get hold of the children of the gcf, H = get(h, 'children')
  4. Finally, search for the handle of the child which containts all the plots.
  5. Suppose H(2) is the child with all the plots, then use H2 = get(H(2), 'children')
  6. Now use set(H2(i)), where i = 1 to number of plots, to list all the properties and change their values.
  7. Similarly, use the get(H2(i)) to fetch the values of all the properties.


For example, the script below extracts data from the plots.


clear all;
% open the .fig file
open test.fig; 
% get the current graph handle
h = gcf; 
% get the children of the figure file
H = get(h, 'Children');
% For this specific case the 2nd child has all the plots
H2 = get(H(2), 'Children');

Y = [];
for i = 1:length(H2)
% get the data of y-axis
    Y = [Y; get(H2(i), 'YData')];
end

Here is a test.fig, i fiddled with using the above script;


..enjoy.
n happy scripting!

~*~*~*~*~~*~*~*~*~

Thursday, July 15, 2010

~ M-ary Constellations

Salam alaik,

M-ary Phase shift keying (PSK) is not only simple but mathematically elegant too.

The symbol values are the Mth root of unity & is given like so:

exp(j.2.\pi.m/M), where m = 0, ..., M-1.


Use the same expression in MATLAB with a bit of rotation for fun :p

% the number of constellation points
M = 16;
m = 0:M-1;

% obtaining the constellation points with pi/M rotation
PSK_16 = exp(j*2*pi*m/M - j*pi/M);



Here is the plot I quickly designed; the Mth roots of unity with rotation..


Try out this 'M-ary_Quadrature_Amplitude_Modulated_Constellation' construction for yourself, & lemme know how good you go.

~*~*~*~*~~*~*~*~*~

Tuesday, July 13, 2010

~ Communication..

Salam alaik,

have been a happy man ever since the advent of VoIP..

VoIP is a wonderful thing for people whose role in life is to be on top of things.
But not for me; my role is to be on the bottom of things.
What I do takes long hours of studying and uninterruptible concentration. I try to learn certain areas of digital communications exhaustively; then I try to digest that knowledge into a form that is accessible to people who don't have time for such study.


Otoh, I need to communicate with hundreds of people all over the world as I write my periodicals.
I also want to be responsive to the people who read & review those articles and have questions or comments.

My goal is to do this communication efficiently, in batch mode --- like, one day every three months. So if you want to talk to me about any topic, please use good ol' snail mail and send a letter to my postal address..
You might also try faxing me. Chances are that it'll be seen last, perhaps once every six months instead of three.
:o)
~*~*~*~*~~*~*~*~*~