我怎样才能在 Matlab 中推断出更高的值?
How can I extrapolate to higher values in Matlab?
我有以下数据:
T=[0,100,300]
和
a=[2.8796,2.8785,2.886]
我想推断并知道我在 Matlab 中 T=600
会得到什么 a
。
我该怎么做?
对于线性插值:
aextra = interp1(T,a,600,'linear','extrap')
如果它是线性的,下面的代码可以解决这个问题
clear all
close all
T=[0,100,300];
a=[2.8796,2.8785,2.886];
reg = polyfit(T,a,1);
figure
hold on
plot(T,a,'bx')
plot(T,reg(2)+T.*reg(1),'k-')
plot(600,reg(2)+600*reg(1),'ro')
plot(600,interp1(T,a,600,'linear','extrap'),'md')
legend('observations','lin. regression','pred. at 600p polyfit','pred. at 600p interp1')
val_polyfit = reg(2)+600*reg(1)
val_interp1 = interp1(T,a,600,'linear','extrap')
diff = val_polyfit/val_interp1
产量
val_polyfit =
2.8924
val_interp1 =
2.8972
diff =
0.9983
我有以下数据:
T=[0,100,300]
和
a=[2.8796,2.8785,2.886]
我想推断并知道我在 Matlab 中 T=600
会得到什么 a
。
我该怎么做?
对于线性插值:
aextra = interp1(T,a,600,'linear','extrap')
如果它是线性的,下面的代码可以解决这个问题
clear all
close all
T=[0,100,300];
a=[2.8796,2.8785,2.886];
reg = polyfit(T,a,1);
figure
hold on
plot(T,a,'bx')
plot(T,reg(2)+T.*reg(1),'k-')
plot(600,reg(2)+600*reg(1),'ro')
plot(600,interp1(T,a,600,'linear','extrap'),'md')
legend('observations','lin. regression','pred. at 600p polyfit','pred. at 600p interp1')
val_polyfit = reg(2)+600*reg(1)
val_interp1 = interp1(T,a,600,'linear','extrap')
diff = val_polyfit/val_interp1
产量
val_polyfit =
2.8924
val_interp1 =
2.8972
diff =
0.9983