Mathematica的使用记录

基础

常用的数

Pi , 或 π
(从基本输入工具栏输入, 或“Esc”+“p”+“Esc”) 圆周率 π

E (从基本输入工具栏输入, 或“Esc”+“ee”+“Esc”) 自然对数的底数e
查看具体数值,保留23位有效数字:

N[E, 23]
2.7182818284590452353603

矩阵操作

导入一个包含一个矩阵的文本:
1 2 3 4 5 6
7 8 9 10 11 12
13 14 15 16 17 18
19 20 21 22 23 24

data = Import["/home/jack/MEGAsync/datamatrx/SVN/src/MATRIX.txt", 
  "Table"]
data[[2, 3]](*某个元素的提取:第2行,第3列*)
data[[3]](*某一行的提取:第3行*)
data[[All, 5]](*某一列的提取:第5列*)
ListPlot[{data[[All, 1]], data[[All, 2]], data[[All, 3]]}, 
Filling -> Top, PlotLegends -> Automatic](*显示第1,2,3列的数据*)

有趣的开源项目

gource 可视化git项目的工具

https://github.com/acaudwell/Gource

##农历
https://github.com/giwhub/zhCal

##命令行有道词典
https://github.com/longcw/youdao

##命令行网易云音乐
https://github.com/darknessomi/musicbox

Ubuntu下图片的各种操作

Ubuntu中有一个强大的图片转换命令:convert

安装:

    sudo  apt-get install imagemagick  

使用:
1. 图片格式转换:

    convert 221622462017.jpg test.png
    convert 221622462017.jpg test.eps
    convert test.png png.eps

2.变形:

    convert -resize 1024x768  hello.jpg   hello_.jpg    # 变形

3.采样:

    convert -sample 20%x20%  hello.jpg  hello_.jpg   # 按比例采样

4.旋转:

    convert -rotate 90 hello.jpg hello_.jpg      # 旋转

5.拼接:

    convert relation.png mfile.png -append question.png #上下拼接两张图为一张

图片格式想怎么转就怎么转。是否很酷呢?
继续阅读“Ubuntu下图片的各种操作”

Gnuplot Examples (1): Plotting With Double-yaxis

Gnuplot is one of the most useful tool for plotting all kinds of figures in Linux system. Here, we give an simple example to plot distribution function with gnuplot. We will plot the function of two kind of molecules A and B in a liquid, along the normal direction (z-axis),ie., as a function of z coordinate. The distribution file are dist_A.dat and dist_B.dat. The value is too different to each other, we plot them with different scale. The details can be found in the script scr_doubleaxis.gnuplot.

To plot, just run
$gnuplot scr_doubleaxis.gnuplot

The script is as follows.
继续阅读“Gnuplot Examples (1): Plotting With Double-yaxis”

Plot histograms in python with matplotlib

Suppose we have a file theta.dat which has 1000 lines and each line has a angle value. Its first 10 lines are as follows.

100.35766
105.05182
112.56954
119.66241
125.35966
127.44947
125.47673
121.08910
118.00765
117.77907

How to plot a histogram figure in python with matplotlib with the file theta.dat?

We put this file in the home directory, thus the position is ~/theta.dat.
Then , we plot in Enthought Canopy Graphical Environment! One can download and install it in Software Manager. If we open it, the window looks like this.

f0

继续阅读“Plot histograms in python with matplotlib”

Linux下使用Keil MDK 开发TM4C123G LaunchPad

Using Keil MDK develop TM4C123G LaunchPad in LinuxMint

Linux下有原生的Code Composer Studio (CCS)可以开发德州仪器的TM4C123G LaunchPad,用起来也很方便。但是我自己在edx上面上了一门课程叫做 “Embedded System --Shape the World”。课程用的是Keil集成开发环境。然而Keil没有Linux的版本,在上课的时候我是用Virtual Box 虚拟了一个Windows XP完成了课程。课程结束之后我参考网络上一些博文结合自己的经验,实现了利用wine安装keil,并成功编译代码,烧写到LaunchPad中。

继续阅读“Linux下使用Keil MDK 开发TM4C123G LaunchPad”

编译含.eps图片的Tex文件时遇到的问题

One solution of "Package pdftex.def Error: File 'eps-converted-to.pdf' not found

The problem:
In Textstudio, when I compile a  tex file including a .eps file, I meet  a error like this:
Error:  ! Package pdftex.def Error: File `P_ba_at_t-eps-converted-to.pdf' not found.
Here is one solution I found from web. MichaelChirico answered this question. The answer is as follows.

继续阅读“编译含.eps图片的Tex文件时遇到的问题”