matlab学习7-线性回归方程,多元,cftool,插值画图

1、多元函数模型rstool x1=[1000 600 1200 500 300 400 1300 1100 1300 300];%收入 x2=[5 7 6 6 8 7 5 4 3 9];%价格 y=[100 75 80 70 50 65 90 100 110 60]';%需求量 x=[x1' x2']; rstool(x,y,'purequadratic') 2、其它多项

1、多元函数模型rstool

x1=[1000 600 1200 500 300 400 1300 1100 1300 300];%收入
x2=[5 7 6 6 8 7 5 4 3 9];%价格
y=[100 75 80 70 50 65 90 100 110 60]';%需求量
x=[x1' x2'];
rstool(x,y,'purequadratic')

2、其它多项式类拟合cftool

拟合模式:

结果判断

3、matalb插值并画图

3.1.一维插值

hours=1:12;
temps=[5 8 9 15 25 29 31 30 22 25 27 24];
h=1:0.1:12;
t=interp1(hours,temps,h,'spline');
plot(hours,temps,'+',h,t,hours,temps,'r:') 
xlabel('Hour'),ylabel('Degrees Celsius')

3.2二维插值(空间上)

x=1:5;
y=1:3;
temps=[82 81 80 82 84;79 63 61 65 81;84 84 82 85 86];
mesh(x,y,temps)
xi=1:0.2:5;
yi=1:0.2:3;
zi=interp2(x,y,temps,xi',yi,'cubic');
mesh(xi,yi,zi)
contour3(xi,yi,zi,[75,75],'r')%空间75等高线图

关键字:matlab, temps, hours, 插值