学习大数据第三天:最小二乘法的MATLAB实现
2016-04-24 10:41
417 查看
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
>>
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
>>
相关文章推荐
- [转]使用MATLAB进行USB摄像头的编程
- matlab求积分
- Matlab基本命令练习
- MATLAB聚类分析(Cluster Analysis)
- matlab global 不能传向量/矩阵
- Matlab_Notebook
- Creo Matlab和MathLink 基于Java的通讯(持续更新)
- matlab保存图片的四种方法&&遇到的一些问题
- 将caffe训练时loss的变化曲线用matlab绘制出来
- ubuntu下caffe配置matlab接口
- matlab isnan
- matlab isnan
- MATLAB入门教程
- matlab实战中一些重要的函数总结
- Matlab实现均匀量化的简单示例
- 用MATLAB设计一个超简单的变声GUI界面
- 写论文第一天:熟悉MATLAB操作
- 物体检测SURF算法matlab实现
- MATLAB函数运算
- matlab 中 x 轴的各种设置