Friday, March 23, 2012

The Beauty of Life

A couple of weeks ago I encountered this talk of Neil deGrasse Tyson. What is the most astonishing fact about the universe? I would thought the warping and such phenomena would be on the list. But No! He talked about how we all, came from the universe. How true, yet how easily forgotten. It reminds me of another video that I've seen  not so long before this. 



It is an animation of the human cells in working. It shows everything we've learned in high school: the making of DNAs and RNAs, the blood cells working their way though the bloodstream.... They are so familiar yet the view is alien to the eyes. How little do we know about ourselves. We are no less alien than the imaginings of our minds. But then again, we are like the stars, we know of its existence,  but little of anything else. We can only do our best to try to understand the work that has been going on in the cosmos since the beginning of time.


What I love about these videos is that they reminds me of the wonderfulness of our existence. To stand on earth, or to be here, at this moment, is a blessing. Sometimes when I feel down, I'd like to remind myself that life is a miracle, and it is worth every second that we cherish it, and love it. When I felt happy, thinking about these facts, I found power in pursuing my dreams. I want to know more! We shouldn't be aliens to ourselves. Sometimes I even believe that, if we work hard enough, if we have enough passion, we would eventually found all answers to our questions.

No matter what the future is installed for us, I want to live it to the fullest. And these videos give me the best reasons to tell people why.

Sunday, March 11, 2012

[Scilab] Plotting with Colors

There had been much frustration when I attempted to plot several locus lines of a four-bar linkage in a single graph. I struggled with the color settings. Searching around the web I find that much of the information given about the use of the plot and plot2d function failed to address how plotting single dots works.

Searching the Scilab online help, we get

plot



LineSpec
This option may be used to specify, in a short and easy manner, how the curves are drawn. It must always be a string containing references to LineStyle, Marker and Color specifiers.
These references must be set inside the string (order is not important) in an unambiguous way. For example, to specify a red long-dashed line with the diamond mark enabled, you can write : 'r--d' or '--dire' or '--reddiam' or another unambiguous statement... or to be totally complete 'diamondred--' (seeLineSpec).
Note that the line style and color, marks color (and sizes) can also be (re-)set throught the polyline entity properties (see polyline_properties).

plot2d



style
This option may be used to specify how the curves are drawn. If this option is specified, the associated value should be a vector with as many entries as curves.
  • if style(i) is strictly positive, the curve is drawn as plain line and style(i) defines the index of the color used to draw the curve (see getcolor). Note that the line style and the thickness can be set through the polyline entity properties (see polyline_properties).
    Piecewise linear interpolation is done between the given curve points.
  • if style(i) is negative or zero, the given curve points are drawn using marks, abs(style(i))defines the mark with id used. Note that the marks color and marks sizes can be set through the polyline entity properties (see polyline_properties).

Pretty clear. So what's the problem?
If I were to do a plot consisting of three "points," say, (1,2), (3,4), and (5,6). They are to be presented as (1) a dot with default color, (2)a red default mark, and (3)a red dot. Using plot, the commend lines would be:
plot(1,2,'.')
plot(3,4,'r')
plot(5,6,'r.')
Whereas using plot2d the commend lines should, according to most tutorials,
plot2d(1,2,style=0), plot2d(1,2,style(0), or plot2d(1,2,0)
X plot2d(3,4,style=1), plot2d(3,4,style(1)), or plot2d(3,4,1)
X plot2d(5,6, style=[0,1], or plot(5,6,[0,1])

The second line is fine if I were plotting lines. (The figure shows the results of the first four commends.) However, not setting the mark style will result in an empty plot. To solve this problem, we would have to change the global property of the plot. I have not yet managed this part, but I shall update it as soon as I figure out how. Stay tuned.