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