11/05/2008

offline missed library in Makefile

When you missed library and can not compile,
you should modify the Makefile
add
"LDFLAGS += -lSpectrum"

10/22/2008

搞定ubuntu下的lsusecure 连接问题

原来是那个certificate 文件没有搞好,需要对全部用户可读,另外后缀要改为.pem

10/21/2008

需要清静的头脑

做科研需要一个专心而清静的头脑,这正是我现在缺乏的。
需要在工作时排除杂念,因为工作就是工作,其他事情放在
工作后再去想。

10/16/2008

在linux中停止某一个进程

  1. 先找到PID for firefox                                                             gyuan@shanghai:~$ pidof firefox                                    
  2. 然后 kill -9 4383
或者
killall -9 firefox

10/14/2008

vi Modes

vi has two modes:

  • command mode
  • insert mode

In command mode, the letters of the keyboard perform editing functions (like moving the cursor, deleting text, etc.). To enter command mode, press the escape key.

In insert mode, the letters you type form words and sentences. Unlike many word processors, vi starts up in command mode.

10/09/2008

新任务

读root tutorial 来找到把数据导入文件和画图的方法,
然后修改JMSelectModule,完成画图,因为

augeroffline是基于root的,所以root 中的函数你都可以
用。

7/31/2008

触摸板问题的解决

症状: touch pad is too sensitive
方法:编辑 /etc/X11/xorg.conf

Section "InputDevice"
Identifier "Synaptics Touchpad"
Driver "synaptics"
Option "SendCoreEvents" "true"
Option "Device" "/dev/psaux"
Option "Protocol" "auto-dev"
Option "MaxTapMove" "10"
Option "SHMConfig" "on"
EndSection

Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Synaptics Touchpad"
InputDevice "Configured Mouse"
InputDevice "stylus" "SendCoreEvents"
InputDevice "cursor" "SendCoreEvents"
InputDevice "eraser" "SendCoreEvents"
EndSection

7/28/2008

宇宙年龄

The age of the universe is the time elapsed between the Big Bang and the present day. Current observations suggest that this is about 13.73 billion years, with an uncertainty of about 120 million years.
or
13.7 +/- 0.2 Gyr

天文距离单位Parsec (pc)

How Distances are Measured in Astronomy

Dealing with the numbers involved with the distances to the stars or even with those found in the solar system can be hard going. Astronomers make their lives easier by using a number of rulers (units of distance) for the distances and although they have some strange names they can be very useful for comparing the distances to stars, other galaxies and even the planets in our solar system.

AU (astronomical units)

One AU is the distance that the average distance that the Earth orbits the Sun at. The AUis most commonly used for the distances of objects with in our solar system. Pluto, the last planet in the solar system is found at an average distance of 39.47 au from the Sun. Sedna the new body nearly as large as a planet found beyond Pluto is never nearer to the Sun than 76AU and then goes to 880AU from the Sun in its giant elliptical orbit.

Light Years

One of the most common rulers is the light year. The light year is is the distance that light travel in one year (365 1/4 days). It is most commonly used for the distances to stars and other galaxies.

The nearest star is 4.2 light years away from our sun. We are 8.3 light minutes away form the Sun. the distance to the outer most planet Pluto is about 13 light hours.

Some other interesting distances in light years:

Object Distance in light years
Nearest Star (Proxima Centuri) 4.2
Sirius the dog star (the brightest star in the sky) 8.6
centre of the galaxy approximately 30 000
Andromeda (one of our nearest neighbouring galaxies) approximately 2 million
The stars of Orion. (Betelgeuse and Rigel) 1400 light years

Parsec (pc)

Astronomers started measuring distances from the amount that a star moves as the Earth goes from one side of the Sun to the other. Try moving your head and you will see that the postion of everything around you changes. One parsec is derived from the smallest angle measurement of 1/3,600th of a degree or an arc second that is the angle that a star at this distance would appear to move in 6 months as the Earth journeys around the Sun. A parsec is 3.2616 light years or 30,857,000,000,000 km.. Two parsecs is 6.5532 light years or twice the distance, it is not a measure of change in angles of the stars. Due to the massive distance in the universe astronomers often use multiples of parsec commonly found are kiloparsec (kpc) a 1000 parsecs or a megaparsec (Mpc) 1,000,000 parsecs.

Below is a conversion table for some useful astronomical distance units

kilometres (km) Astronomical units (AU) Light Years (l.y.) Parsec (pc)
kilometres (km) 1 149.6 million 9,460,000,000,000 30,857,000,000,000
Astronomical units (AU) 0.0000000067 1 63,240 206,263
Light Years (l.y.) 0.00000000000011 0.000016 1 3.2616
Parsec (pc) 0.000000000000033 0.0000048 0.3066 1

7/23/2008

如何解决windows屏幕歪斜的问题

ctrl+alt+ 上下左右,可使屏幕旋转

7/22/2008

Network Manager按钮丢失的问题

在panel里添加notification area就好了。

7/21/2008

mathematica 字体 透明 问题

在linux有时mathematica会有 字体透明问题,起根本原因是x文件冲突
解决办法是
在运行 mathematica 之前运行
export XLIB_SKIP_ARGB_VISUALS=1

很无奈但是没别的办法。

mathematica 安装


luoyang 7101-55824-64326 L2735-7617 6707-157-705:2:8:20090901
学校的License
最后一长串数字是密码

解决ubuntu 下字体缺乏的问题

sudo apt-get install msttcorefonts

6/23/2008

哈佛的凌晨四点


哈佛的凌晨四点(相信大家看过很多遍了,我发仅供个人励志用) 2008-03-24 00:12


1.现在睡觉的话会做梦 而现在学习的话会让梦实现
This moment will nap, you will have a dream; But this moment study,you will interpret a dream.

2.我无所事事地度过的今天是昨天死去的人们所奢望的明天
I leave uncultivated today, was precisely yesterday

perishes tomorrow which person of the body implored.

3.感到晚了的时候其实是最快的时候
Thought is already is late, exactly is the earliest time.

4.不要把今天的事拖到明天
Not matter of the today will drag tomorrow.

5.学习的痛苦是一时的 而没有学习的痛苦是一辈子的
Time the study pain is temporary, has not learned the pain islife-long.

6.学习不是人生的全部 但连学习都征服不了 你还能做什么?
The study certainly is not the life complete. But, sincecontinually life part of - studies also is unable to conquer, what butalso can make?

7.学习不是因为缺少时间而是缺少努力
Studies this matter, lacks the time, but is lacks diligently.

8.所有人的成功都不是偶然的
Nobody can casually succeed, it comes from the thoroughself-control and the will.

9. 无法避免的痛苦就去享受吧!
Please enjoy the pain which is unable to avoid.

10.早起的鸟儿有虫吃
Only has compared to the others early, diligently diligently, canfeel the successful taste.

11.成功并不属于每个人
Nobody can casually succeed

12.时间在流逝
HOW time flies

13.今天流下的口水将变成明天流下的泪水
Now drips the saliva, will become tomorrow the tear.

14. 像狗一样学习
The dog equally study, the gentleman equally plays.

15.如果今天不走的话 明天就要跑
Today does not walk, will have to run tomorrow.

16.为未来投资的人是对现实忠实的人
The investment future person will be, will be loyal to the realityperson.

17.学历就是金钱
The education level represents the income.

18.今天度过的一天明天就找不回来了
One day, has not been able again to come.

19.即使现在这一瞬间对手的书桌还堆满了书
Even if the present, the match does not stop changes the page.

20.No pains no gains不劳无获

6/17/2008

使用特定端口登录

$ ssh -p 22 user@hostname //使用端口22

ip地址的获取

flyriver@luoyang:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:15:c5:6a:e1:df
inet addr:xxx.xx.xxx.xxx

清空terminal的指令是clear

~$ clear

TCanvas指令后各个参数的意义

c1 = new TCanvas("c1","The Cascade example",200,10,700,900);

“c1”:名字
"The Cascade example": Title
200: 像素的左起点
10:像素的上起点
700,900:整个画布是700*900的像素

6/14/2008

root中函数调用问题的解决

发现root中函数调用跟C++中的没有区别。

void hello(char *name)
{
// print hello name
cout << "hello " << name << endl;
}


void air() //此处名字要跟文件名‘air.C’保持一致
{

Int_t j;

for(j=0;j<5;j++)
{

hello("World!");

}
}

6/12/2008

Filling Histogram with weight

Filling histograms

An histogram is typically filled with statements like:
       h1->Fill(x);
h1->Fill(x,w); fill with weight
h2->Fill(x,y)
h2->Fill(x,y,w)
h3->Fill(x,y,z)
h3->Fill(x,y,z,w)
这里的w是weight.

6/09/2008

root指数分布的产生方法

px=gRandom->Exp(36);
这里的px 就是一个符合exp(-x/36)分布的随机数。

6/06/2008

Reset and Debug

Reset:
gROOT->Reset()

  1. Calls destructors of all objects created on the stack
  2. Objects on Heap are not deleted, but pointer variable is disassociated
Debug:
  • .e continue to end of the function
  • .c continue to next breakpoint
  • .c 45 continue to line 45
  • .p print the value of var
  • .b 34 sets a break point at line 34
  • .db 34 removes the break point at line 34

root commands

运行.C命令
Usage: root [-l] [-b] [-n] [-q] [file1.C ... fileN.C]
Options:
-b : run in batch mode without graphics
-n : do not execute logon and logoff macros as specified in .rootrc
-q : exit after processing command line macro files
-l : do not show splash screen

root[0].?
this command will list all the CINT commands
root[1].X [filename]
load [filename] and execute function [filename]
root[2].L [filename]
load [filename]
root[3].ls
ls on current directory
root[4].pwd
list the current directory, canvas, and style.
root [5] TBrowser b
get the information of .root file

useful linux commands

tar -zxfv madwifi-cvs-20051025.tar.gz
Will uncompress the downloaded file

z means “Gunzip(uncompress) it before extracting, used on file ending in .tar.gz or .tgz”
x means “Extract the contents of the TAR file”
f means “Filename to follow”
v means “Verbose - display contents as it is tarring or extracting”

Open office.org的命令
oobase oodraw oofromtemplate ooweb
oomath 数学公式
oocalc 表格
ooffice 综合
ooimpress PPT
ooo-wrapper
oowriter 文档
Adobe Reader的命令
flyriver@luoyang:~$ acroread
This script is in the /Adobe/Reader8/bin

RealPlayer的命令
flyriver@luoyang:~$ realplay
This script is in the /usr/bin/RealPlayer

Evince的命令
flyriver@luoyang:~/Desktop/root_test/test$ evince test.pdf
这个软件适用于以下格式:
  • PDF
  • Postscript
  • djvu
  • tiff
  • dvi

6/05/2008

C++ compiler in linux

$ g++ helloWorld.cpp

$ ./a.out

6/04/2008

root 规律总结

类型 规律 例子
  1. Classes begin with T TTree, TBrowser
  2. Non-class types end with _t Int_t
  3. Data members begin with f fTree
  4. Member functions begin with a capital Loop()
  5. Constants begin with k kInitialSize kRed
  6. Static variables begin with g gEnv
  7. Static data members begin with fg fgTokenClient

root help文件内容

Note1: Cint is not aimed to be a 100%% ANSI/ISO compliant C/C++ language
processor. It rather is a portable script language environment which
is close enough to the standard C++.

Note2: Regulary check either of /tmp /usr/tmp /temp /windows/temp directory
and remove temp-files which are accidentally left by cint.

Note3: Cint reads source file on-the-fly from the file system. Do not change
the active source during cint run. Use -C option or C1 command otherwise.

Note4: In source code trace mode, cint sometimes displays extra-characters.
This is harmless. Please ignore.

CINT/ROOT C/C++ interpreter interface.
All commands must be preceded by a . (dot), except
for the evaluation statement { } and the ?.
===========================================================================
> [file] : output redirection to [file]
2> [file] : error redirection to [file]
>& [file] : output&error redirection to [file]
? : help
help : help
/[keyword] : search keyword in help information
Shell: ![shell] : execute shell command
Source: v <[line]>: view source code
V [stack] : view source code in function call stack
t : show function call stack
f [file] : select file to debug
T : turn on/off trace mode for all source
J [stat] : Set warning level [0-5]
A [1|0] : allowing automatic variable on/off
trace : turn on trace mode for class
deltrace : turn off trace mode for class
Evaluation: p [expr] : evaluate expression (no declaration/loop/condition)
Evaluation: s [expr] : step into expression (no declaration/loop/condition)
Evaluation: S [expr] : step over expression (no declaration/loop/condition)
{[statements]} : evaluate statement (any kind)
x [file] : load [file] and execute function [file](wo extension)
X [file] : load [file] and execute function [file](wo extension)
E <[file]>: open editor and evaluate {statements} in the file
Load/Unload: L [file] : load [file]
La [file] : reload all files loaded after [file]
U [file] : unload [file]
C [1|0] : copy source to $TMPDIR (on/off)
undo : undo previous declarations
lang : local language (EUC,SJIS,EUROPEAN,UNKNOWN)
Monitor: g <[var]> : list global variable
l <[var]> : list local variable
proto <[scope]::>[func] : show function prototype
class <[name]> : show class definition (one level)
Class <[name]> : show class definition (all level)
typedef : show typedefs
function : show interpreted functions
macro : show macro functions
template : show templates
include : show include paths
file : show loaded files
where : show current file position
refcount : reference count control on/off
cover [file] : save trace coverage
return [val] : return undefined symbol value
Run: S : step over function/loop
s : step into function/loop
i : ignore and step over
c <[line]>: continue
e : step out from function
f [file] : select file to debug
b [line] : set break point
db [line] : delete break point
a [assert]:
break only if assertion is true
O [0~4] :
Set bytecode compiler mode

Quit:
q : quit cint
qqq :
quit cint - mandatory

save :
call emergency routine to save important data

Notes for learning root 06/04/2008

TH1F :
histograms with one float per channel. Maximum precision 7 digits

Quit root (just in case)
root[0]>.q

Display the browser
root[1]>TBrowser b;

C++ 在root中使用时,基本规则不变只是具体的写法有些区别
具体为
第一个字母大写,然后加上"_t"
例如:
int-->Int_t
double-->Double_t
char-->Char_t

which I think it is totally stupid , but anyway , I need to follow their
rules if I want to use it.

6/03/2008

安装 root 的注意事项--亲身体会

真是不容易
1 先下载root 的源文件。
我用的是这个:root_v5.19.04.source.tar.gz
2 解压缩
tar -xvzf root_v5.24.00.source.tar.gz
之后产生了root的文件夹
3 安装
安装路径
set ROOTSYS to the `root' directory:
sh family:
$ export ROOTSYS=
/home/flyriver/downloads/root
   3.1 $  ./configure --help
3.2 $ ./configure linux //for intel 32 bit machine
( ./configure linuxx8664gcc)// for amd 64 machine

3.3 if gcc is not installed
$sudo apt-get install build-essential,libX11-dev,libxft-dev,xorg-dev

3.4$ make [or, make -j2 for dual CPU machines]
3.5$ make install

4 此时只能在这个文件夹下的目录下运行,若想让root在所有文件夹
下都可以运行,或者你就把文件解压缩/usr/local/bin然后安装,
或者你需要编辑库文件,/etc/ld.so.conf,需要管理员帐号,将
root的lib位置告诉它,也就是添加一行,
include /etc/ld.so.conf.d/*.conf
/usr/lib/atlas
/usr/local/lib
/home/flyriver/downloads/root/lib //此行为后来添加
5 这里还没有完,需要编译ld.so.conf,然后更改才能生效。
具体为在管理员帐号下运行 ldconfig指令
root@luoyang:/home/flyriver# ldconfig

终于,在折腾了三天之后,将root安装在自己的电脑上了,爽!!!!!

*************************************************************
如果上面的方法不起作用,你所需要做的是,编辑
.profile
文件


# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
PATH=~/bin:"${PATH}"
fi
之后 , 添加
PATH=/home/gyuan/downloads/root/bin:$PATH
export PATH
结束后,log off 然后 login 即可

下面是更详细的
  1. To add that PATH to every user but root, add the line(s) to /etc/profile
  2. To add that PATH to root, add those line(s) to /root/.profile
  3. To add that PATH to a specific user(s), add the line(s) to /home/user/.profile





运行 root的 先行步骤

以下指令只能保证root 在这个文件夹下可以使用
flyriver@luoyang:~/downloads$ export ROOTSYS=/home/flyriver/downloads/root

flyriver@luoyang:~/downloads$ export PATH=$ROOTSYS/bin:$PATH

flyriver@luoyang:~/downloads$ export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH

英文信封的写法

Step1
To address an envelope, print the return address neatly in the upper left-hand corner of the envelope.
Step2
Begin by writing the sender's name and/or the company's name on the first line of the address.
Step3
Add the sender's street address (include Ave., St. or Blvd., as well as apartment, office or suite number) or post office (P.O.) box number on the second line.
Step4
Include mail-stop numbers, for mail distribution within a large company, where an apartment or suite number would appear on the second line.
Step5
Print the city name followed by a space, the two-letter capitalized state abbreviation and the ZIP code (five-digit or ZIP+4) on the third line.
Step6
Include the country name, if necessary, in capital letters on the fourth line of the address.
Step7
Print the mailing address (the destination address) in the center of the envelope or package, putting each element of the address in the same order as outlined in Steps 1 through 6 above.
Step8
Attach proper postage to the upper right-hand corner of the envelope, on the same side of the envelope as the destination address and return address.

5/30/2008

libXpm package 缺失的解决办法

sudo apt-get install libxpm-dev
这样就解决了安装root软件中的一个关键问题

Keyboard Shortcuts for Bash ( Command Shell for Ubuntu, Debian, Suse, Redhat, Linux, etc)

Ctrl + A Go to the beginning of the line you are currently typing on
Ctrl + E Go to the end of the line you are currently typing on
Ctrl + L Clears the Screen, similar to the clear command
Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + R Let's you search through previously used commands
Ctrl + C Kill whatever you are running
Ctrl + D Exit the current shell
Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.

Alt + F Move cursor forward one word on the current line
Alt + B Move cursor backward one word on the current line
Tab Auto-complete files and folder names

run .c file in root

use
gyuan@frankie ~ $ root hsimple.C

or after open root

use

root [4] .x hsimple.C

5/19/2008

编辑双系统电脑的boot 顺序

sudo pico /boot/grub/menu.lst
然后把
title Windows XP
root (hd0,0)
makeactive
chainloader +1

贴到

## ## End Default Options ##
之下,就搞定了!

5/04/2008

mathematica 画图


Plot[f(x),{x,-4,4},PlotRange->{0,0.5},AxesLabel->{x,y}]

4/30/2008

Mathematica中的FindFit命令

当你知道一些点和拟合曲线的理论形式时,非常推荐用
mathematica的FindFit指令来估测参数值。


Here is a list of points.
In[1]:=

This finds the values of c and d that give the best linear approximation to points.

In[2]:=

Out[2]=




4/27/2008

matlab点的类型

y     yellow           .     point
m magenta 紫红色 o circle
c cyan 蓝绿色 x x-mark
r red + plus
g green - solid
b blue * star
w white : dotted
k black -. dashdot
-- dashed

4/26/2008

Matlab 关系运算符和逻辑运算符

To construct conditions, MATLAB provides six relational operators

tabular180

and three logical operators.

tabular185


*Note that the relational operator == compares two arguments, while = is used to assign a value to a variable.

4/22/2008

C++中如何判断整除与否?

int main()
{
int a=10,b=3;
if(a%b==0)
printf("能被整除");
else
printf("不能被整除");
}

4/20/2008

matlab中输出结果到文件的新方法

例子
clear;
fid=fopen('answers.txt','w');
fprintf(fid,'My Name is Qiaofeng, I am from China. \r\n');
fprintf(fid,'I travelled a lot. \r\n');
for i=1:3
j=3*i;
fprintf(fid,'When I was %u years old, I went to City %u . \r\n',j,i);
end

status=fclose(fid);
输出
My Name is Qiaofeng, I am from China.
I travelled a lot.
When I was 3 years old, I went to City 1 .
When I was 6 years old, I went to City 2 .
When I was 9 years old, I went to City 3 .
(zz)
"\r"指的是“回车”符号,即回到本行的开头,
"\n"指的是“换行”符号,即开始新的一行,
根据我的使用经验,在fprintf函数中两者结合使用,
才能达到在新的一行的开头开始打印的目的。
附:matlab输出格式,(from www.mathworks.com)


%6.2f表示输出数字小数点左六位,右两位
例2:
n =

984.1240


fprintf(myfid,'n= %6.1f\r\n n=%2.6f\r\n')
输出如下
n= 984.1
n=984.124000

CharacterDescriptionExample
Field widthA string specifying the minimum number of characters to be printed. This includes a plus or minus sign, any leading zeros, numeric digits, and decimal point.%6f
PrecisionA string including a period (.) specifying the number of digits to be printed to the right of the decimal point%6.2f

Conversion Characters

Conversion characters specify the notation of the output.
SpecifierDescription
%cSingle character
%dDecimal notation (signed)
%eExponential notation (using a lowercase e as in 3.1415e+00)
%EExponential notation (using an uppercase E as in 3.1415E+00)
%f Fixed-point notation
%g The more compact of %e or %f, as defined in [2]. Insignificant zeros do not print.
%GSame as %g, but using an uppercase E
%oOctal notation (unsigned)
%sString of characters
%uDecimal notation (unsigned)
%xHexadecimal notation (using lowercase letters af)
%XHexadecimal notation (using uppercase letters AF)
The following tables describe the nonalphanumeric characters found in format specification strings.

Escape Characters


This table lists the escape character sequences you use to specify non-printing characters in a format specification.
CharacterDescription
\b Backspace
\f Form feed
\n New line
\r Carriage return
\t Horizontal tab
\\ Backslash
\''
(two single quotes)
Single quotation mark
%% Percent character

4/10/2008

physics trainning

The training in physics is priceless, you need to be confident with your abilities. But you may consider other options if your career goal is not in academia. The earlier you think about that , the better preparation you will have.

Prof. Steve Hsu
University of Oregon

3/27/2008

矩阵的转置共轭就是厄米变换

conjugate transpose, Hermitian transpose, or adjoint matrix of an m-by-n matrix A with complex entries is the n-by-m matrix A* obtained from A by taking the transpose and then taking the complex conjugate of each entry. The conjugate transpose is formally defined by
(A^*)_{i,j} = \overline{A_{j,i}}

where the subscripts denote the i,j-th entry, for 1 ≤ in and 1 ≤ jm, and the overbar denotes a scalar complex conjugate. (The complex conjugate of a + bi, where a and b are reals, is abi.)

This definition can also be written as

A^* = (\overline{A})^\mathrm{T} = \overline{A^\mathrm{T}}

where A^\mathrm{T} \,\! denotes the transpose and  \overline A \,\! denotes the matrix with complex conjugated entries.

Other names for the conjugate transpose of a matrix are Hermitian conjugate, or transjugate. The conjugate transpose of a matrix A can be denoted by any of these symbols:

3/26/2008

matlab中画图技巧



例:t=0:0.1:10
y1=sin(t);y2=cos(t);plot(t,y1,'r',t,y2,'b--');
x=[1.7*pi;1.6*pi];//设定不同曲线的位置
y=[-0.3;0.8];
s=['sin(t)';'cos(t)']; // 不同曲线的标题
text(x,y,s);
title('正弦和余弦曲线');
legend('正弦','余弦') //分别不同的曲线
xlabel('时间t'),ylabel('正弦、余弦')
grid on

matlab中解析解和数值解一起求

方法就是先用syms 指令将其符号化,然后解方程得到解析解
然后将参数赋值,用eval 指令将其数值解求出。
例子

%hw6prob3

clear;
syms gamma omega delta;
diary hw6prob3.txt;
A1=[-gamma, i*omega,-i*omega,0;i*omega,-(gamma/2+i*delta),0,-i*omega;-i*omega,0,-(gamma/2-i*delta),i*omega;1,0,0,1],

B=[0;0;0;1],

X1=A1\B;
fprintf('The analytical solution for this linear equation is: \n ');
X1,

gamma=1;
omega=2;
delta=0;

fprintf('The numerical solution for this linear equation is: \n ');
X2=eval(X1),

diary off;

matlab中semicolon(分号)的巨大作用

To make Matlab give an output, such as return the value of a variable, you type the name of the variable without any semicolon (;) following the variable.
如果需要显示的话,不要加分号
In many cases, there is no need to see the value of a variable every single time Matlab uses it. If Matlab re-computes the value of a variable 1000 times, we probably don't want to see the result every single time. To surpress the output of a value, just add a semi colon after the variable. Then Matlab will perform the command, but will not show it on the screen.
不需要显示中间过程的话,加上分号.

例子
%solve linear equations

clear;
diary hw6prob2.txt;
fprintf('This just shows 5*5 matrix but 100*100 is basically the same.\n');
fprintf('The result for 100*100 matrix is just too large to show on one paper.\n');
N=5;
for j=1:N,
for i=1:N,
A(i,j) = 1/(i+j-1);//这里需要加上分号,这样可以不显示中间过程
end
end

for n=1:N;
B(n,1)=1/n;
end

A, //这里需要显示结果,所以不能加分号
B,

X=A\B;
fprintf('The solution for this linear equation is: \n ');
X,

diary off;

3/25/2008

matlab矩阵除法

推荐使用
z = A\b;

不推荐使用

y = inv(A)*b;

matlab中输出结果到文件

使用diary 命令,这里是一个例子。

%solve linear equations
diary hw6prob1.txt;
clear;
A=[4,-2,1;3,6,-4;2,1,8];
B=[20;-30;40];

Y=inv(A);
X=Y*B;
fprintf('The answers is: \n ');
X,
The
Y,
diary off;
红色的是关键所在,这两个命令之后,中间输出的X, Y就保存在
hw6prob1.txt
请看输出结果
The answers is:

X =

2.3194
-2.9658
4.7909


Y =

0.1977 0.0646 0.0076
-0.1217 0.1141 0.0722
-0.0342 -0.0304 0.1141