本文介绍了如何在Matlab中外推更高的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下数据:

T=[0,100,300]

a=[2.8796,2.8785,2.886]

,我想推断并知道在Matlab中的T=600会得到什么a.我该怎么办?

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

推荐答案

如果线性,下面的代码可以解决此问题

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

收益

val_polyfit =

    2.8924


val_interp1 =

    2.8972


diff =

    0.9983

这篇关于如何在Matlab中外推更高的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 16:50