# ある時間の値(予測)

1 view (last 30 days)
qrqr on 13 Feb 2019
Commented: qrqr on 14 Feb 2019

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)
この時、1秒の時、2秒の時、3秒の時・・・の値を求めることはできますか？

madhan ravi on 13 Feb 2019
Edited: madhan ravi on 13 Feb 2019
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')
qrqr on 14 Feb 2019

Umekawa Yutaro on 13 Feb 2019
こんな形はいかがでしょうか．

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); %多項式近似（例で２次多項式として）
estimatedLine = polyval(p,time2); %近似した多項式の計算
plot(time,data, time2, estimatedLine, 'o');
qrqr on 14 Feb 2019

R2013b

### Community Treasure Hunt

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

Start Hunting!