2009年8月17日星期一

Latex:多行公式使用同一个编号(等号对齐)

\usepackage{amsmath}


...
\begin{equation}
\begin{split}
x = & a \\
=& b.
\end{split}
\end{equation}

2009年8月11日星期二

Latex: 在公式中使用黑体的希腊字母

有时候在书写数学公式是,希望使用黑体的字母。普通字母可以使用\textbf{}来显示黑体。但是希腊字母不能用这个命令,编译会出错。但可以使用\boldsymbol{}命令。例如:\boldsymbol{\pi}。使用这条命令时,需要在文档头引用amsmath包:\usepackage{amsmath}。

Latex:多个公式使用同一个编号(右对齐)

\usepackage{amsmath}


\begin{equation}
\begin{aligned}
equation 1 ... \\
equation 2 ... \\
equation 3 ...
\end{aligned}
\end{equation}

生成的公式只有一个编号,并且自动右对齐。

2009年7月17日星期五

Scilab: subplot

If one wants to plot several subfigures in a large figure, the command is subplot.

Calling Sequence :

subplot(m,n,p)
subplot(mnp)

Parameters :

m,n,p : positive integers.

Here m means the line number, n means the column number, p means the subfigure number. Just imagine the large figure is an m×n matrix and each element in it is a subfigure.

The following code generates this picture.




ff = fscanfMat('D:\WORK\Scilab\spc-only-Ez1.txt');
t = ff(:,1);

scf(1);clf(1); //create figure 1, and clean it.
Ez = ff(:,2);
subplot(2,2,1) //figure 1 contains 4 subfigures, this is the first one.
plot(t,Ez,'k.','markersize',3); //plot the first subfigure
xtitle("Ez at z = 10um");
xgrid(1);
a=get("current_axes");
a.x_label.text="t*C(m)";
a.y_label.text="Ez(MV/m)";

Ez = ff(:,3);
subplot(2,2,2) //figure 1 contains 4 subfigures, this is the second one.
plot(t,Ez,'k.','markersize',3); //plot the second subfigure
xtitle("Ez at z = 20um");
xgrid(1);
a=get("current_axes");
a.x_label.text="t*C(m)";
a.y_label.text="Ez(MV/m)";

Ez = ff(:,4);
subplot(2,2,3) //figure 1 contains 4 subfigures, this is the third one.
plot(t,Ez,'k.','markersize',3); // plot the third subfigure.
xtitle("Ez at z = 30um");
xgrid(1);
a=get("current_axes");
a.x_label.text="t*C(m)";
a.y_label.text="Ez(MV/m)";

2009年6月18日星期四

Scilab: format

In order to show more digits on the screen in Scilab, we can call the "format" command.

Calling Sequence:

format([type],[long])
format()

Parameters
type : character string. "v" for a variable format (default), and "e": for the e-format.
long : integer ( max number of digits (default 10))


In the variable format, a number is shown from the higher order digits to the lower order digits in a natural way. One gets 1 digit less than the [long] he sets. Say one sets [long] = 10, then he get 9 digits on the screen including the point. See the following example.

-->pi = 4*atan(1);

-->format('v',5); pi
pi =

3.14

-->format('v',10); pi
pi =

3.1415927



In the e-format, it seems that the number is shown in scientific notation. The [long] means the length, and one gets one digit less. Since the length includes the point and the exponential part, a number less than 8 does not make sense. See the following examples.

-->format('e',7); pi
pi =

3.1D+00

-->format('e',8); pi
pi =

3.1D+00

-->format('e',9); pi
pi =

3.14D+00

-->format('e',12); pi
pi =

3.14159D+00


format() gives out the current format by 2 numbers. The first number shows the format, 0 for 'v' and 1 for 'e', and the second number shows the length.

Ref: Scilab 4.1.2 browse help.