ある時間の値(予測)

3 次查看(过去 30 天)
qrqr
qrqr 2019-2-13
评论: qrqr 2019-2-14
以下のデータがあります。
time = [0,0.64,1.28,1.92,2.56,3.2,3.84,4.48]
data = [0,0.5,1.5,2.5,3.5,4.5,5.5,6.5]
plot(time,data)
untitled.png
この時、1秒の時、2秒の時、3秒の時・・・の値を求めることはできますか?

采纳的回答

madhan ravi
madhan ravi 2019-2-13
编辑:madhan ravi 2019-2-13
Just use interp1() (see the method it provides and adapt it to your needs):
time = [0,0.64,1.28,1.92,2.56,3.2,3.84,4.48];
data = [0,0.5,1.5,2.5,3.5,4.5,5.5,6.5];
plot(time,data)
hold on
Values=interp1(time,data,1:3);
% ^^^---- 1 to 3 seconds , linear interpolation see the link for other methods
plot(1:3,Values,'+k')
  1 个评论
qrqr
qrqr 2019-2-14
皆様、ありがとうございます。

请先登录,再进行评论。

更多回答(1 个)

Umekawa Yutaro
Umekawa Yutaro 2019-2-13
こんな形はいかがでしょうか.
元のデータを多項式近似し,その多項式より新たにデータを取得したい時刻のインデックスを持つ配列を作成し求めたい値を取得します.
近似の対象区間や多項式の次数などは対象のデータに合わせて取捨選択してあげればよいかと思います.
time = [0,0.64,1.28,1.92,2.56,3.2,3.84,4.48];
data = [0,0.5,1.5,2.5,3.5,4.5,5.5,6.5];
plot(time,data)
time2 = [1:3]; % 求めたい時刻
p = polyfit(time,data, 2); %多項式近似(例で2次多項式として)
estimatedLine = polyval(p,time2); %近似した多項式の計算
plot(time,data, time2, estimatedLine, 'o');
  1 个评论
qrqr
qrqr 2019-2-14
皆様、ありがとうございます。

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品


版本

R2013b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!