1.点乘:对应元素相乘
A =
1 2
3 4
>> A2=A*A
A2 =
7 10
15 22
>> A2=A.*A
A2 =
1 4
9 16
2.polyfit(x,y,n):分别为自变量、因变量、最高位数
>> x=0:0.3:3
x =
Columns 1 through 7
0 0.3000 0.6000 0.9000 1.2000 1.5000 1.8000
Columns 8 through 11
2.1000 2.4000 2.7000 3.0000
>> y=4+x.^3+3*x.^2+2
y =
Columns 1 through 7
6.0000 6.2970 7.2960 9.1590 12.0480 16.1250 21.5520
Columns 8 through 11
28.4910 37.1040 47.5530 60.0000
>> y1=polyfit(x,y,3)
y1 =
1.0000 3.0000 0.0000 6.0000
3.另外一个例子:
>> x=[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]
x =
Columns 1 through 7
0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000
Columns 8 through 10
0.8000 0.9000 1.0000
>> y=[2.3201,2.6470,2.9070,3.2885,3.6008,3.9090,4.2147,4.5191,4.8232,5.1275]
y =
Columns 1 through 7
2.3201 2.6470 2.9070 3.2885 3.6008 3.9090 4.2147
Columns 8 through 10
4.5191 4.8232 5.1275
>> p=polyfit(x,y,1)
p =
3.1301 2.0141
>>