How can I extrapolate to higher values in Matlab? [closed]

回眸只為那壹抹淺笑 提交于 2019-12-02 05:04:48

问题


I have the following data:

T=[0,100,300]

and

a=[2.8796,2.8785,2.886]

and I want to extrapolate and know what a will I get at T=600 in Matlab. How can I do that?


回答1:


If its linear the code below solves this

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

yields

val_polyfit =

    2.8924


val_interp1 =

    2.8972


diff =

    0.9983



回答2:


For Linear Interpolation: aextra = interp1(T,a,600,'linear','extrap')



来源:https://stackoverflow.com/questions/33808862/how-can-i-extrapolate-to-higher-values-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!