Spline interpolation in matlab

2 Ansichten (letzte 30 Tage)
Rachel Chung
Rachel Chung am 25 Mär. 2015
Beantwortet: dpb am 25 Mär. 2015
I have the following:
x = 1:365;
y = T;
xx = missing;
yy = interp1(x,y,xx,'spline')
I have data `T`, which is 365 days of data, and `missing` is a vector containing the days on which the data is faulty. I need to generate estimated values at the missing days. However, when I use the above syntax, it returned a vector of all the same value. I made some changes, got an error, deleted them, and now with the same syntax I'm getting the error on line 4:
You can not subscript a table using only one subscript. Table subscripting
requires both row and variable subscripts.
What am I doing wrong?
  2 Kommentare
Christiaan
Christiaan am 25 Mär. 2015
Dear Rachel,
Could you send us the mat-file of 'T' and 'missing'? A small example, how the interp1 function works, I have posted below for you.
clc; clear all; close all;
x = 1:365;
y = sin(x);
xx = [1 3 4];
yy = interp1(x,y,xx,'spline')
Kind regards, Christiaan
Rachel Chung
Rachel Chung am 25 Mär. 2015
here's the file!

Melden Sie sich an, um zu kommentieren.

Antworten (1)

dpb
dpb am 25 Mär. 2015
Your T vector has zero-valued entries for the missing locations and so there is a data value at that day and therefore interp1 returns that value (0) instead of an interpolated value.
T(missing)=[]; % remove the missing locations
t=1:365; t(missing)=[]; % the correlating full day vector
yy=interp1(t,T,missing,'spline')

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by