Sunday, December 30, 2007

Sunday, December 16, 2007

Print PDF files in black and white

Under MAC OSX, adobe reader doesn't allow you to choose whether to print in black&white or in color. Use Preview instead. The steps are as such
1. Print
2. Color Sync
3. Quatz filter: Black & White

Wednesday, December 5, 2007

1. erase all configureations in Cisco routers:
erase start
reload

2. Initial configuration of Cisco routers:
2.1 no ip domain lookup and logging synchronous
2.2 set an ip address on one interface along with the vty password, so that I can telnet myself.
2.3 set "enable secret", keep enabled, telnet myself using the address configured above to test the password.

Tuesday, December 4, 2007

position of boxes in LaTaX

Take one kind of box for example, the minipage box.

\begin{minipage}[position]{width}

There are 3 options for "position" , namely , c, t, b, meaning centre, top and bottom correspondingly.
If 'c' is chosen, the vertical center of the minipage will be aligned to the baseline of the surrounding environment.
If 't' is chosen, the vertical top of the minipage will be aligned to the baseline of the surrounding environment.
If 'b' is chosen, the vertical bottom of the minipage will be aligned to the baseline of the surrounding environment.

Sunday, December 2, 2007

Referencing to a float in LaTeX

With \label and \ref, you can create a reference to a float within
your text. Note that the \label command must come after the \caption
command since you want it to reference the number of the caption.

Saturday, December 1, 2007

Using Chinese in TeXShop

TeXShop is the mac os version of TeXLive.
Using Chinese here is different from that in CTeX. I don't know exactly what happens yet, but I do know one way to use Chinese under TeXShop environment, which is followed:

\usepackage{CJKutf8}
\begin{CJK}{UTF8}{gbsn}
...
\end{CJK}

Monday, November 26, 2007

copy folders in sftp

[from http://www.cae.wisc.edu/site/public/?title=linux-sftp]
Recursive Copy

If you try to copy a folder using the get or mget commands, sftp will complain that it "Cannot download non-regular file: filename". This is because the basic sftp client doesn't allow for a recursive copy. However, the program scp will allow you to do this. The scp command will not allow you to see what's on the sftp server, so the files need to be located using the sftp client.

Note: the scp command is a Unix command, and needs to be run from the Unix prompt. NOT within the SFTP client.

Usage: scp user@host:remote-path local-path

scp is like the Unix command cp and should work similarly. To copy a file from your Unix home directory and put it in the working directory, use the following command:

scp @sftp.cae.wisc.edu:~/ ./

Where is your CAE username, and is the file you wish to copy. Enter your password when scp asks for it. scp works just like a get command in sftp.

To recursively copy files or directories from your CAE account, use the -r switch.

For example, to copy the entire directory "tutorial" from my CAE Unix home directory to the home directory on your machine, the following command would be used:

ComputerName:~ # scp -r username@sftp.cae.wisc.edu:~/tutorial ~/

Where username is your CAE username.

Sunday, November 25, 2007

Download a whole website using "wget"

Use the following command:
wget -r -p -np -k {url}
where
-r means recursive
-p means page requisites
-np means no parent
-k means convert.

man wget to get the details

Monday, November 12, 2007

Rotating in LaTeX

\usepackage{rotating}
you can use three new environments:
1. \begin{sideways}
it will rotate the whole argument by 90 degrees counterclockwise. Moreover:
2. \begin{turn}{30}
it will turn the argument of 30 degrees. You can give any angle as an argument, whether it is positive or negative. It will leave the necessary space to avoid any overlapping of text.
3. \begin{rotate}{30}
like turn, but it will not add any extra space.

Thursday, November 8, 2007

Mutual Inductance in PSpice Schematics

Using pure Spice programming instead of PSpice schematics could easily puts an mutual inductance "K" between two inductors "L1" and "L2"by typing:
"K L1 L2 0.02"
where 0.02 is the coupling coefficient.
However, for no reason I decided to use PSpice schematics to analyze the crosstalk of several inductors, as illustrated in the figure below:


It is indeed easy to find out the part for mutual inductance in PSpice is "K_linear". However, when it came to specify "L1" and "L2", I became confused. After half an hour's searching on the internet, finally I got the answer from MIT open courseware.

Now let's do it step by step:
1.Double click the one of the K_linear element (it is suggested to click on the squared K)to open the property editor, as show in the following figure(In this example, I double clicked K2)

2.Now look at the columns with "L1" "L2" "L3" "L4" "L5" "L6" as headers, among which column header "L1" is for the primary inductor, the rest 5 columns are for secondary inductors. In this example, only the first two columns are needed for each "K_linear". As we can see from the last figure, the mutual inductors for "K2" is "L3" and "L4", thus what we need is to input "L3" under the first column, that is, the column of L1; input "L4" under the second column, that is , the column of L2.
3.Complete configuring the other K_linear using the principles above.

After all these efforts, I suddenly realized that I had never read any book about PSpice. From college what I had done was all based on the instruction sheet given by my teachers, which means my knowledge base for PSpice is far from enough. In fact, it can't even be called "Knowledge base", they are "Knowledge pieces". Next I need to seriously read one book.

At last, MIT open course ware is really great. Take use of it!!!

Sunday, November 4, 2007

Downloading a bunch of files in unix

This article talks about how to download a bunch of files named sequentially:

1st Choice:

Use "curl"
for example:

curl -O http://www.jcedu.org/2/jq/dcd/mp3/[01-30].mp3

pay attention to the option "O" ,which means remote names. It will write output to local files with the same name as the remote files we get. Otherwise all data will be printed in the terminal, which means we will get nothing.

2nd Choice

Use "wget" by shell scripting
for example:

to get the same files as above, edit a script like this:

#!/bin/sh
for ((i=1;i<10;i++))
do wget http://www.jcedu.org/2/jq/dcd/mp3/0"$i".mp3
done
for ((i=10;i<31;i++))
do wget http://www.jcedu.org/2/jq/dcd/mp3/"$i".mp3
done
exit 0

Wednesday, October 31, 2007

several tips for LaTeX

1. To crop image while including it:

\includegraphics[trim=l b r t,clip=true]{*.png}

where "l" means the length to me eliminated from the left of the image, while "b", "r", "t" means that from the bottom, right and top of the image.
to make trim work, clip has to be set as true.

2. \framebox and \lstinputlisting could be used together to produce a fancy output.

Monday, September 17, 2007

Remember

Thousands of people are suffering and dying while I write this, while you read this. How easy it is for us to ignore this obvious fact. How we easily lie to us that horrible things are highly impossible to happen to "me".

This life is short. Do not waste it!

Sunday, September 16, 2007

Make It Slow

Eight years ago, I realized that time is precious thus I should try my best to do every thing as fast as possible, in the meantime, never neglect even a tiny period of time, even the 10 minutes between classes. Later I found out that as a human being, I have to get some rest, so I did have some fun in the 10 minutes break. But the habit to do things fast has been kept until now, since it is actually a part of my born characteristics.

Usually when I did something very fast, I was driven by the strong desire to complete it. All the strong desires are a torture to our hearts.

Now, I realize another more important truth, that a peaceful heart is most enjoyable and couldn't be sacrificed for anything else. The fact is, when you do something under a peaceful heart without haste, you could do it more efficiently. This is a wise and natural choice after comparison.

Just keep yourself clear of what you are up against and what you should do, then do it one by one, step by step without any haste. Make it slow.

Thursday, September 6, 2007

Consequences

There are two ideas that I am impressed by in the movie Matrix.

The first one is the shock that the world we are living with our joy and sorrow suddenly becomes imaginary. Later I found a similar idea, which is more reasonable by the way, in what Siddhartha said more than two thousand years ago----Nothing you see, hear, smell, taste, feel, think or do is real. This idea I am not able to fully understand for now. Thus I'd like to illustrate the other one----Consequences.

In that movie, Merv says that "Where some see coincidences, I see consequences; Where others see chance, I see cost". Concequences(因果) is a too frequently used word in China that everyone knows it without paying attention to it. When someone riding a bicycle is hit by a car, people may probably consider it as an "accident",which is, of course, a coincidence. However, if you think about it, either the rider or the driver moves too fast, or they are just thinking something else without paying attention to the vicinity. The truth is, there is no such thing as coincidence. Every thing is the consequence of some and the reason of others. If a student doesn't solve the problems immediately after he meets them, the final exam will be a huge pressure; If a fish is seduced by the bait, it will probably end up with your food in the table. In fact mostly the relation between reasons and consequences are neither that clear nor direct, you'll have to be careful to think further. One thing leads to another.

When you want to do something, you'd better think about the possible consequences; When you are undergoing something or watching something terrible from any kind of media, think about the reasons under the surface, and if that is something you are possible to do, warn yourself, keep yourself from doing that, which is a natural choice.

Also when you are eager to accomplish something, think about the necessary conditions you need, and satisfy them. You don't even have to keep eagerous, just be totally clear about what you should do and do it. The consequence will come unavoidably.

Monday, April 23, 2007

matlab数字图像处理常用的函数

imread(‘filename’): 支持的格式有tiff, jpeg, gif, bmp, png, xwd.
imwrite(‘filename’): 支持的格式同imread.
imshow(f,G): f是图像文件,G是灰度级数,默认256级.
imfinfo: 了解图像文件的信息
imadd: 将两幅图像相加或把常数加到图像
imsubtract: 将两幅图像相减或从图像中减去常数
immultiply:将两幅图像对应像素相乘或图像乘以常数
imdivide: 两幅图像相除或图像除以常数
imabsdiff: 计算两幅图像间的绝对差
imcomplement: 对图像求补
imlincomb: 两幅或多幅图像的线性组合
imadjust(f,[low_in, high_in],[low_out, high_out],gamma):对图像进行亮度变换
imhist(f,b): f是图像文件,b是灰度级的个数
histeq(f,hspec): Enhance contrast using histogram equalization.其中f是输入图像,hspec是指定的直方图.
imfilter: 线性空间滤波
colfilt及nlfilt: 非线性滤波
fspecial: 生成线性空间滤波器
ordfilt2: 生成非线性空间滤波器
imnoise: 添加噪声
roipoly: 选择感兴趣的区域
checkerboard: 产生测试板图像
deconvblind: 盲去卷积
intransform:空间变换

Wednesday, April 18, 2007

有意思的传统节日

一月一:
自然是新年,无需多说

二月二:
龙抬头

三月三:汉族传统节日,旧称“上巳日”,时在夏历三月初三日。古时以三月第一个巳日为“上巳”,汉代定为节日。“是月上巳,官民皆絜(洁)于东流水上,曰洗濯祓除,去宿垢疢(病),为大絜”(《后汉书·礼仪志上》)。后又增加了临水宴宾、踏青的内容。魏晋以后,上巳节改为三月三,后代沿袭,遂成汉族水边饮宴、郊外游春的节日。该日民间有流杯、流卵、流枣、乞子和戴柳圈、探春、踏青、吃清精饭以及歌会等活动。台湾、福建地区三月三为“三月节”,“采鼠麹(曲)草,合米粉为粿以祀其先”(清乾隆《台湾府志》)。四川忠县等地有“三月会”,举行纪念抗敌将领巴蔓子的盛大活动,是日,群众抬巴蔓子的偶像绕城游行,后跟社火队,玩龙灯、舞狮子,家家张灯结彩,燃放爆竹,热闹非凡。我国南方许多少数民族的传统节日。壮族,多于三月三赶歌圩,搭歌棚,举办歌会,青年男女们对歌、碰蛋、抛绣球,谈情说爱。相传为纪念壮族歌仙刘三姐而形成的节日,故又称歌仙节。侗族,多于节日举行抢花炮、斗牛、斗马、对歌、踩堂等活动,亦称“花炮节”。布依族,于节日杀猪祭社神、山神,吃黄糯米饭,各寨三四天内不相往来。瑶族以三月三为“干巴节”,是集体渔猎的节日,并将捕获的野物鱼类按户分配,共享收获的欢乐,后云集于广场,唱歌跳舞,欢度佳节。畲族以三月三为谷米的生日,家家吃乌米饭。黎族称三月三为“孚念孚”,为预祝“山兰”(山地旱谷)和打猎丰收的节日,也是青年男女自由交往的日子。其他如水族、苗族、仫佬、毛南等族都有各自传统的三月三节日习俗。

四月四:
每年四月四日,清明节的前一天。传说,这个节日,是纪念春秋的介之推的。   介之推是当年晋国的贤臣,侍奉公子重耳(后为晋文公)。晋国发生内乱,公子重耳被迫逃亡国外,介之推不畏艰难困苦跟随重耳流亡;曾经割自己腿肉熬汤,献给重耳。重耳做了国君后,开始时还铭记介之推,但是时间久了,也把他淡忘了。介之推心中十分难受,和其年迈的母亲回到家乡,隐居在山中。   有一天,晋文公发现自己左右少了介之推,想起自己忘了奖赏这个"割股奉君"的贤臣,非常内疚,亲自跑到他隐居的山中寻找。但是只见山峦重叠,葱苍树木,就是不见介之推的影子。他想,介之推是个孝子,如果放火烧山,他一定会背着母亲出来。于是,命令放火烧山,结果火一下蔓延数十里,连烧三日不熄,但介之推没有出来。火熄之后,大家进山察看,才发现介之推和他的老母相抱在一起,被烧死在深山之中。   这事传出来,人人尊敬和怀念介之推。以后便在他被烧死的这天纪念他,这天就在每年四月清明节的前一天。因为介之推是被火烧死的,大家在这天都不忍心举火,宁愿吞吃冷食,所以,这天叫"寒食节"。

五月五:
端午,也无需多说

六月六:
"六月六,请姑姑"。过去,每逢农历六月初六,农村的风俗都要请回已出嫁的老少姑娘,好好招待一番再送回去。
相传在春秋战国时期,晋国有个宰相叫狐偃。他是保护和跟随文公重耳流亡到列国的功臣,封相后勤理朝政,十分精明能干,晋国上下对他都很敬重。每逢六月初六狐偃过生日的时候,总有无数的人给他拜寿送礼。就这样狐偃慢慢地骄傲起来。时间一长,人们对他不满了。但狐偃权高势重,人们都对他敢怒不敢言。
狐偃的女儿亲家是当时的功臣赵衰。他对狐偃的作为很反感,就直言相劝。但狐偃听不进苦口良言,当众责骂亲家。赵衰年老体弱,不久因气而死。他的儿子恨岳父不讲仁义,决心为父报仇。
第二年,晋国夏粮遭灾,狐偃出京放粮,临走时说,六月初六一定赶回来过生日。狐偃的女婿得到这个消息,决定六月初六大闹寿筵,杀狐偃,报父仇。狐偃的女婿见到妻子。问她:"像我岳父那样的人,天下的老百姓恨不恨?"狐偃的女儿对父亲的作为也很生气,顺口答道:"连你我都恨他,还用说别人?"他丈夫就把计划说出来。他妻子听了,脸一红一白,说:"我是你家的人,顾不得娘家了,你看着办吧!"
从此以后,狐偃的女儿整天心惊肉跳,她恨父亲狂妄自大,对亲家绝情。但转念想起父亲的好,亲生女儿不能见死不救。她最后在六月初五跑回娘家告诉母亲丈夫的计划。母亲大惊,急忙连夜给狐偃送信。
狐偃的女婿见妻子逃跑了,知道机密败露,闷在家里等狐偃来收拾自己。
六月初六一早,狐偃亲自来到亲家府上,狐偃见了女婿就像没事一样,翁婿二人并马回相府去了。那年拜寿筵上,狐偃说:"老夫今年放粮,亲见百姓疾苦,深知我近年来做事有错。今天贤婿设计害我,虽然过于狠毒,但事没办成,他是为民除害,为父报仇,老夫决不怪罪。女儿救父危机,尽了大孝,理当受我一拜。并望贤婿看在我面上,不计仇恨,两相和好!"从此以后,狐偃真心改过,翁婿比以前更加亲近。为了永远记取这个教训,狐偃每年六月六都要请回闺女、女婿团聚一番。这件事情张扬出去,老百姓各个仿效,也都在六月六接回闺女,应个消仇解怨、免灾去难的吉利。年长日久,相沿成习,流传至今,人们称为"姑姑节"。

七月七:
七夕乃牛郎织女相会的日子,也不必多说.

八月八:
缺(其实我想说这一天是明朝的开国皇帝朱重八同志(或称朱八八同志)的生日)

九月九:
九九重阳.

十月十:


十一月十一:


十二月十二:

Tuesday, April 17, 2007

cepstrum and matlab

the signal processing tool box of matlab provides three functions for cepstrum analysis:
cceps: complex cepstrum
icceps: inverse complex cepstrum
rceps: real cepstrum

Monday, April 16, 2007

数值积分及matlab

数值积分的适用情况:
1. 被积的是解析式,但原函数无法用初等函数表示
2. 被积的不是解析式,而是离散的矩阵

在这两种情况下使用数值积分来近似。主要的数值积分方法有
Newton-Cotes 公式、
Romberg 方法、
Euler-Maclaurin公式、
Gauss型求积公式

称一个结点的Newton-Cotes公式为矩形公式
称两个结点的Newton-Cotes公式为梯形公式
称三个结点的Newton-Cotes公式为Simpson公式

称Weighting function为1的Gauss积分为Lobatto quadrature
___________________________________________________________________

matlab直接提供的数值积分函数主要有:trapz, quad, quadl.
trapz使用的是梯形公式,trapezoid numerical integration
quad使用的是Simpson公式, adaptive simpson quadrature
quadl使用的是 adaptive Lobatto quadrature
(曾经的quad8已经过时)

Thursday, March 8, 2007

Stationary Signals



1. General illustration
The first natural division of all signals is into either stationary or non-stationary categories. Stationary signals are constant in their statistical parameters over time. If you look at a stationary signal for a few moments and then wait an hour and look at it again, it would look essentially the same, i.e. its overall level would be about the same and its amplitude distribution and standard deviation would be about the same. Rotating machinery generally produces stationary vibration signals.
Stationary signals are further divided into deterministic and random signals. Random signals are unpredictable in their frequency content and their amplitude level, but they still have relatively uniform statistical characteristics over time. Examples of random signals are rain falling on a roof, jet engine noise, turbulence in pump flow patterns and cavitation. In fact, most random signals in nature could be treated as wide-sense stationary.
2. Mathematically
Reference to the picture from the article "The empirical mode decomposition and theHilbert spectrum for nonlinear andnon-stationary time series analysis" by Norden E. Huang et. al. Page 3




On Instantaneous Frequency

Instantaneous Frequency的定义是相位的导数,不是初相的,不可搞混